我有一个使用以下框架构建的项目:
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0</TargetFrameworks>
这在我的本地计算机上编译正常,但是当我将其推送到Azure时,它将失败。
当我的YAML文件中包含以下内容时:
variables:
solution: '**/*.sln'
buildConfiguration: 'Release'
buildPlatform: 'Any CPU'
platform: x64
- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: '**/*.csproj'
arguments: '--configuration $(buildConfiguration)'
然后我得到:
## [错误] C:\ Program Files \ dotnet \ sdk \ 3.1.403 \ Microsoft.Common.CurrentVersion.targets(1177,5):错误MSB3644:找不到.NETFramework,Version = v5.0的参考程序集。若要解决此问题,请为此框架版本安装Developer Pack(SDK / Targeting Pack)或重新定位您的应用程序。您可以在https://aka.ms/msbuild/developerpacks下载.NET Framework Developer Pack。
如果我尝试
- task: VSBuild@1
displayName: 'Build all'
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
maximumCpuCount: true
我得到:
## [错误] C:\ Program Files(x86)\ Microsoft Visual Studio \ 2019 \ Enterprise \ MSBuild \ Current \ Bin \ Microsoft.Common.CurrentVersion.targets(1177,5):错误MSB3644:.NETFramework的参考程序集,找不到版本= v5.0。若要解决此问题,请为此框架版本安装Developer Pack(SDK / Targeting Pack)或重新定位您的应用程序。您可以在https://aka.ms/msbuild/developerpacks下载.NET Framework Developer Pack。
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
您的项目无法成功构建的原因是因为Microsoft托管的代理未安装.NET 5.0 SDK。
您可以使用Use.NET Core Task下载.NET 5.0 SDK :
- task: UseDotNet@2
inputs:
packageType: 'sdk'
Version: '{version}'
includePreviewVersions: {true/false}
此任务可以从网络下载特定版本的.Net SDK,并将其添加到PATH。
此外,由于在项目中使用的是.NET的多个版本,因此可以使用此任务来指定在以下任务中使用的.NET版本。
换句话说,此任务具有两个功能:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句