PowerShell exit code - Calling from MSBuild

后端 未结 3 1312
渐次进展
渐次进展 2020-12-30 07:49

I\'m invoking a PowerShell script from MSBuild. MSBuild is able to capture the output returned, but thinks the project is built successfully.

The problem is that th

3条回答
  •  旧时难觅i
    2020-12-30 08:15

    I tried several options but none works for me.

    To capture the powershell error on msbuild target, best way is to return the error code from powershell script like $host.SetShouldExit($remotelastexitcode).

    e.g. test1.ps1

    function CallFromMSBuild {
    
       Invoke-command {Powershell.exe C:\a.ps1} -computername $computers
       $host.SetShouldExit(1)
    } 
    
    
            
            
            
          
    

    Worth to have a look at https://snagify.wordpress.com/2008/04/06/teambuild-powershell-and-exit-codes/

提交回复
热议问题