我在azure中使用了“Use .Net Core”任务来使用下面的全局json来安装SDK。
{
"sdk": {
"version": "6.0.410",
"rollForward": "disable",
"allowPrerelease": false
}
}
但之后在下一个 .Net Core -
"Build"
命令管道任务中,在构建应用程序时,它使用 MSBuild version 17.7.1 instead using 17.6.8
。
早些时候它是正确接收的
MS Build version 17.6.8
,这个问题几天前就开始了。
有没有办法指定在.Net Core -“Build”命令管道任务中使用哪个MSBuild版本?为什么它没有选择与SDK相关的正确版本?
我也尝试在
"Use .Net Core"
任务中指定确切的 SDK 版本,并指定兼容的 Visual Studio
版本。
我尝试使用下面的
yaml code
与 MS Build
一起运行 .net version 6.0.410
并且管道成功运行,如下所示:-
YAML 代码:-
trigger:
- main
pool:
vmImage: 'windows-latest'
variables:
solution: '$(System.DefaultWorkingDirectory)/WebApplication5.sln' # Update the path to your .sln file if needed
stages:
- stage: Build
jobs:
- job: Build
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '6.0.410'
installationPath: $(Agent.ToolsDirectory)/dotnet
- powershell: |
dotnet nuget locals all --clear
dotnet --version
dotnet restore ${{variables.solution}}
dotnet build ${{variables.solution}} --configuration Release
displayName: 'Restore and Build'
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '6.0.410'
- task: MSBuild@1
inputs:
solution: ${{variables.solution}}
msbuildArguments: '/p:Configuration=Release' # Adjust this as needed
platform: 'Any CPU'
logProjectEvents: true
clean: true
displayName: 'Build with MSBuild'
- powershell: |
# Run any additional tasks here
# For example, you can publish your application or run tests
displayName: 'Run Additional Tasks'
输出:-
global.json:-
{
"sdk": {
"version": "6.0.410",
"rollForward": "disable",
"allowPrerelease": false
}
}