首页 > 解决方案 > 在 Microsoft 托管的 Azure Devops Build Pipeline Agent 上安装 Visual Studio 2015 工具包 (v140)

问题描述

我有一个遗留解决方案,我们已将其移至 Azure Devops git 存储库,我正在尝试为其设置构建管道。该解决方案是 v141 (2017) 和 v140 (2015) 项目的混合,只要我安装了 v140 工具集,我就可以在我的本地计算机上构建 Visual Studio 2017。

理想情况下,我想使用 Microsoft 提供的代理,但似乎 vs2017-win2016 映像默认不包含 v140 工具集。由于这不是我们计划经常构建的东西,我尝试使用 2017 安装程序安装 v140 工具集:

pool:
    vmImage: 'vs2017-win2016'

steps:
- task: PowerShell@2
  displayName: 'Install Visual Studio v140 Toolset'
  inputs:
    targetType: 'inline'
    script: |
      Write-Output "Starting the installation process. This will take some time"
      $installProcess = Start-Process -FilePath $(Build.SourcesDirectory)/External/VisualStudioBuildTools/installer.exe -ArgumentList "--add Microsoft.VisualStudio.Component.VC.140", "--quiet", "--wait", "--norestart" -Wait -PassThru
      Write-Output "Install Completed with code $($process.ExitCode)"

- task: VSBuild@1
  displayName: 'Build Debug [.sln]'
  inputs:
    solution: '$(Build.SourcesDirectory)/LegacySolution.sln'
    vsVersion: '15.0'
    configuration: 'Debug'
    platform: 'x64'

当我在 Azure Devops 中运行它时,安装过程在大约一分钟后以代码 0(成功)退出。但是,当它尝试构建解决方案时,它会失败:

##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Platform.targets(67,5): Error MSB8020: The build tools for v140 (Platform Toolset = 'v140') cannot be found. To build using the v140 build tools, please install v140 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution".

有没有人幸运地尝试过这个?我能想到的唯一另一件事是尝试签入 v140 工具集的副本并尝试将其正确添加到路径中,但我可以看到这是正确的主要痛苦!

标签: azure-devopsvisual-studio-2017-build-tools

解决方案


在 Microsoft 托管的 Azure Devops Build Pipeline Agent 上安装 Visual Studio 2015 工具包 (v140)

一般来说你不能。如果某事需要管理员访问权限并且您正在使用托管代理,则不能执行该操作。我已经在本地测试了这个命令行,我需要用管理员运行powershell,否则我会得到一个确认提示。

此外,MS 回复:

VS 已经发展到一个地步,在同一个代理上安装多个版本对我们来说不再可行。此外,我们注意到某些项目类型的并行 VS 安装存在问题。出于这些原因,我们决定继续使用单一工具集。如果您需要多个版本,则必须设置自定义代理。很抱歉,我们无法使用通用托管代理映像满足所有客户的要求。

所以,要解决这个问题,我们必须设置我们的私人代理。

希望这可以帮助。


推荐阅读