azure-devops - Devops 构建管道 yaml - 当前的 .NET SDK 不支持针对 .NET Standard 2.0
问题描述
目前我们使用 (git) Bitbucket 作为源代码控制,使用 Bamboo 进行构建和部署。
我们的项目之一是遗留.NET Framework 4.7.2
MVC 应用程序。该解决方案中的一些项目曾经迁移到netstandard2.0
. 所以主 MVC 项目是.NET Framework 4.7.2
,解决方案中的所有其他项目要么也是.NET Framework 4.7.2
,要么netstandard2.0
。
Visual Studio (2019) 在构建和运行整个解决方案时没有问题。Bamboo 在构建和部署解决方案方面也没有任何问题。Bamboo 使用 MSBuild 构建。
但是,当我在 Azure DevOps 中使用相同的 MSBuild 配置时,会出现构建错误。我猜是因为项目中混合了 .NET SDK 版本。
我的azure-pipelines.yml
样子是这样的:
trigger:
- master
pool:
# also tried VS2019, but got same errors during build
vmImage: 'VS2017-Win2016'
variables:
solution: 'WebSolution.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:Configuration=web-develop /p:DeployOnBuild=false /p:PublishProfile=web.pubxml /p:AllowUntrustedCertificate=True'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
但是,为什么 Azure DevOps 会抱怨 SDK 框架的混合?为什么 Visual Studio 和 Bamboo 能够毫无问题地构建解决方案?
A compatible SDK version for global.json version: [2.0.2] from [D:\a\1\s\global.json] was not found
##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets(126,5): Error : The current .NET SDK does not support targeting .NET Standard 2.0. Either target .NET Standard 1.6 or lower, or use a version of the .NET SDK that supports .NET Standard 2.0.
Project "D:\a\1\s\WebSolution.Bc.Common\WebSolution.Bc.Common.csproj" (2) is building "D:\a\1\s\Web.WebData\Web.WebData.csproj" (4:2) on node 1 (default targets).
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets(126,5): error : The current .NET SDK does not support targeting .NET Standard 2.0. Either target .NET Standard 1.6 or lower, or use a version of the .NET SDK that supports .NET Standard 2.0. [D:\a\1\s\Web.WebData\Web.WebData.csproj]
有没有办法在 DevOps 中解决这个问题,而无需将解决方案中的每个项目都迁移到 .NET Core?
解决方案
推荐阅读
- random - 在python中生成多边形范围内的随机点数
- python - 如何计算两个以上边界框的联合交集?
- fortran - 带有 MPI 的 2D FFTW 太慢了
- c++ - 使用指针从类中引用和更改全局变量
- excel - VBA代码将工作表上传到URL,文件名来自特定单元格
- java - Java 输出循环问题
- python-3.x - 向 TCP 服务器添加异步功能?
- javascript - 如何异步执行多个 mongoose 查询并等待它们全部执行完毕后再发送响应?
- python - 在 Python HTTP 客户端 urllib3 和请求之间进行选择
- phpunit - 无法在 phpunit 中运行 Drupal::service()