【发布时间】:2018-02-20 23:43:13
【问题描述】:
我有一个执行以下操作的 PowerShell 脚本:
- 使用 devenv.exe 升级旧的 Visual Studio 解决方案。
- 使用 MSBuild 构建升级后的 Visual Studio 解决方案。
如果我运行此脚本,我会收到一条错误消息,指出“MSBUILD:错误 MSB3428:无法加载 Visual C++ 组件“VCBuild.exe”。 要解决此问题,1) 安装 .NET Framework 2.0 SDK,2) 安装 Microsoft Visua l Studio 2005 or 3) 将组件的位置添加到系统路径中,如果 安装在别处。”
让我感到奇怪的是,如果在看到错误消息后重新运行脚本,我可以成功升级并构建解决方案。我尝试在多台机器上运行脚本,并且仅在第一次尝试执行脚本时才看到错误消息。随后的尝试都成功了。
我使用的是 Windows 10、PowerShell 5.1 版和 Visual Studio 2015 Community。
这里是相关的sn-p代码:
$DevenvExe = 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe'
$MsBuildExe = 'C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe'
$SolutionPath = "$CurrentPath\portaudio\build\msvc\portaudio.sln"
& $DevenvExe $SolutionPath /upgrade
& $MsBuildExe $SolutionPath /p:Configuration=Release /p:Platform=x64 /nr:false /m:4
if ($?) {
Write-Host "Success"
} else {
# This piece of code executes, followed by the MSBUILD error
Write-Host "PortAudio did not successfully build." -ForegroundColor Red
Write-Host "Please refer to the Operation Manual for instructions to build PortAudio." -ForegroundColor Red
}
可能发生了什么导致错误在第一次执行迭代时发生,但在所有其他尝试中都成功?
【问题讨论】:
标签: visual-studio powershell msbuild