You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何强制Azure Pipeline使用指定版本的MSBuild 17.5.1

问题:Azure Pipeline中强制使用MSBuild 17.5.1版本

问题背景

SDK 7.0.302搭配MSBuild 17.6.x存在Razor文件构建问题,导致Azure Pipeline构建失败。此前使用SDK 7.0.203搭配MSBuild 17.5.1时构建完全正常。

原YAML配置

- task: UseDotNet@2
  displayName: 'Use .NET Core SDK 7.0.x'
  inputs:
    packageType: 'sdk'
    version: '7.0.x'

当前配置与现象

已将配置修改为使用对应Visual Studio 17.5.4的SDK 7.0.203,SDK版本显示正确,但构建过程仍调用MSBuild 17.6.1,构建日志关键片段如下:

Starting: Build
==============================================================================
Task         : .NET Core
Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version      : 2.221.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
C:\Windows\system32\chcp.com 65001
Active code page: 65001
Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
C:\Agent\_work\_tool\dotnet\dotnet.exe build C:\Agent\_work\7\s\Gigantisch.Afas.Api\Gigantisch.Afas.Api.csproj "-dl:CentralLogger,\"C:\Agent\_work\_tasks\DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b\2.221.0\dotnet-build-helpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll\"*ForwardingLogger,\"C:\Agent\_work\_tasks\DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b\2.221.0\dotnet-build-helpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll\"" --configuration Release
**MSBuild version 17.6.1+8ffc3fe3d for .NET**

已尝试的方案

  • 指定SDK 7.0.202并添加参数vsVersion: '17.5.2'
  • 切换至MSBuild@1任务

以上方案均无法成功让构建使用17.5.x版本的MSBuild。

疑问

是否可以强制Azure Pipeline的构建过程使用MSBuild 17.5.1版本?


内容的提问来源于stack exchange,提问作者TheSjoerd

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 14:05:38