[英]Start-Process fails with msbuild with write-error in powershell
我嘗試做這樣的非常簡單的事情,但由於異常而失敗:
Build-VisualStudioSolution <<<<
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Build-VisualStudioSolution
簡單的腳本就是這樣。 當我從命令行運行相同命令時,就可以了。
@buildArgs = "C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe C:\WORK\test\test.sln /t:build"
try{
Start-Process @BuildArgs
}
catch{
Write-Error ($_.Message);
}
謝謝提示
首先,如果您只想打印錯誤,則無需捕獲。
其次,您的語法錯誤。 它看起來應該像這樣:
$buildArgs = "C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe", C:\WORK\test\test.sln", "/t:build"
Start-Process @BuildArgs
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.