繁体   English   中英

启动过程因msbuild失败而在Powershell中出现写错误

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM