[英]Azure DevOps build fails after upgrading app to from ASP.NET Core 2.2 to ASP.NET Core 3.1
我有一個在本地運行良好的構建(VSCode、.NET Core 3.1.101),但在 Azure DevOps Pipeline 中運行時失敗並顯示以下消息。
我的管道被簡化為最基本的:
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
這會導致此錯誤消息:
.NET Core SDK 3.1.101 版至少需要 MSBuild 16.3.0 版。 MSBuild 的當前可用版本是 15.9.21.664。 將 global.json 中指定的 .NET Core SDK 更改為需要當前可用的 MSBuild 版本的舊版本。
我找不到一種方法來更改管道運行的 MSBuild 版本並更改為舊版本的 .NET Core 肯定會破壞升級的目的?
有沒有辦法在 Azure DevOps 上構建 .NET Core 3.1 解決方案?
我在任何地方都看不到您有 dotnet 構建任務,您需要配置版本的 dotnetbuild 任務,
steps:
- task: UseDotNet@2
displayName: ".NET Core 3.1.x"
inputs:
version: '3.1.x'
packageType: sdk
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
參考這篇文章。
您應該能夠恢復 nuget 包,使用此 YAML 編譯 nad 運行單元測試
pool:
vmImage: 'windows-latest'
variables:
buildConfiguration: 'Release'
rootDirectory: '$(Build.SourcesDirectory)'
steps:
- task: DotNetCoreCLI@2
displayName: Restore nuget packages
inputs:
command: restore
projects: '**/*.csproj'
workingDirectory: $(rootDirectory)
- task: DotNetCoreCLI@2
displayName: Build
inputs:
command: build
projects: '$(rootDirectory)/*.sln'
arguments: '--configuration $(buildConfiguration)'
# You just added coverlet.collector to use 'XPlat Code Coverage'
- task: DotNetCoreCLI@2
displayName: Test
inputs:
command: test
projects: '*Tests/*.csproj'
arguments: '--configuration $(buildConfiguration) --collect:"XPlat Code Coverage" -- RunConfiguration.DisableAppDomain=true'
workingDirectory: $(rootDirectory)
我假設您的解決方案文件位於根目錄中。 如果您使用全局 json,請將 sdk 版本設置為3.1.201
否則可能需要另一個 steo。
全局文件
{
"sdk": {
"version": "3.1.201",
"rollForward": "latestFeature"
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.