我有一个遗留解决方案,我们已经将其移至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工具集的副本并正确地将其添加到路径中,但是我发现这是正确的主要难题!
答案 0 :(得分:1)
在Microsoft托管的Azure Devops构建管道代理上安装Visual Studio 2015工具包(v140)
通常您不能。如果某些操作需要管理员访问权限,并且您正在使用托管代理,则不能执行此操作。我已经在本地测试了此命令行,我需要使用Administrator运行powershell,否则,将收到确认提示。
此外,微软回答:
VS已经发展到一定程度,可以在 同一个代理商对我们而言不再可行。另外,我们注意到问题 在某些项目类型的并行VS安装中。对于这些 原因,我们决定继续使用单个工具集。如果 您需要多个版本,那么您将必须设置自定义 代理商。很抱歉,我们无法满足所有客户的需求 使用通用托管代理映像的要求。
因此,要解决此问题,我们必须设置我们的私人代理。
希望这会有所帮助。