我有一个遗留解决方案,我们已将其移至 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 工具集的副本并尝试将其正确添加到路径中,但我可以看到这是正确的主要痛苦!