开发者

Start-Process fails with msbuild with write-error in powershell

开发者 https://www.devze.com 2023-03-15 10:07 出处:网络
I try do something very simple like this but it fails with exception: Build-VisualStudioSolution <<<<

I try do something very simple like this but it fails with exception:

Build-VisualStudioSolution <<<<   
    + CategoryInfo          : NotSpecified: (:) [Write-Erro开发者_Python百科r], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Build-VisualStudioSolution

simple script is like that. When I run the same from command line it is fine.

@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);            
}    

thanks for tips


First thing, you don't need to catch if you just want to print the error.

Second, your syntax is wrong. It should look like this:

$buildArgs = "C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe", C:\WORK\test\test.sln", "/t:build"

Start-Process @BuildArgs 
0

精彩评论

暂无评论...
验证码 换一张
取 消