我正在使用DotNetCoreCLI任务来构建一个项目。但我想用MSBuild 16.0来构建它,目前似乎不可能。以下是事实(摘自Azure Pipelines Yaml):
pool:
vmImage: 'windows-2019'
steps:
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
projects: '$(BuildProjectFilter)'
arguments: '--configuration $(BuildConfiguration) -:Platform=$(BuildPlatform) -p:VisualStudioVersion=16.0 -p:tv=16.0'
无论我尝试什么,dotnet build命令始终使用ToolsVersion 15.0版本:
==============================================================================
Task : .NET Core
Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version : 2.156.1
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
[command]C:\windows\system32\chcp.com 65001
Active code page: 65001
[command]"C:\Program Files\dotnet\dotnet.exe" build d:\a\1\s\src\xxx.csproj --configuration release -p:Platform=x64 -p:VisualStudioVersion=16.0 -p:tv=16.0
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
如果我只提供-tv:16.0开关,MSBuild就会抱怨:
MSBUILD : error MSB1040: ToolsVersion is not valid. The tools version "16.0" is unrecognized. Available tools versions are "15.0".
如果我提供 -p:VisualStudioVersion=16.0 -p:tv=16.0 ,结合Fody,稍后会识别出错误。
Fody is only supported on MSBuild 16 and above. Current version: 15.
当然,降级Fody可能是一个解决方案。但我更想使用MSBuild 16,因为它应该在此vm镜像中可用。是否有一种方法实现这一点?