Xav*_*nas 31 msbuild powershell
我正在使用Powershell编写构建脚本.这些脚本执行各种操作,例如从SVN获取最新的源代码,备份等,并使用MSBuild构建解决方案:
cmd /c C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild.exe "C:\Dev\Path\MyProjct.sln" /p:Configuration=Release
Run Code Online (Sandbox Code Playgroud)
在这条指令之后,如果编译成功,我只想执行其余的脚本.我怎么检查这个?
该项目是一个Web项目,因此检查输出并不容易,但我猜一些变量将包含编译结果.此外,因为我用cmd/c调用msbuild,我能够访问这些变量吗?
Kei*_*ill 38
$LastExitCode在调用MSBUILD后检查右边的值.如果为0,则MSBUILD成功,否则失败.
BTW没有必要使用cmd/c.只需直接调用MSBUILD.exe即可.我们一直在PowerShell构建脚本中这样做.
Jay*_*uzi 10
要检查成功/失败,请使用自动变量$?.
PS> help about_Automatic_Variables
$?
Contains the execution status of the last operation. It contains
TRUE if the last operation succeeded and FALSE if it failed.
例如:
msbuild
if (! $?) { throw "msbuild failed" }