I have a console application that coded in C# that is used in my TFS release process, if this application encounters an error it will display the error then return a non-zero error code, looks like this:
try
{
//Does stuff...
return 0; //where 0 = success
}
catch (Exception ex)
{
Console.WriteLine("Error in Main: " + ex.Message + "\n" + ex.StackTrace);
for (int i = 0; i < args.Length; i++)
{
Console.WriteLine("Value in args[" + i + "]: " + (i == 3 ? "**********" : args[i]));
}
//Return error state
return 1;
}
It is invoked by a PowerShell script in TFS that looks like this:
# (Does some parsing stuff...)
echo $abc
Start-Process -FilePath $abc-ArgumentList $arguments -NoNewWindow -PassThru -Wait
Now my problem is that sometime the console app fails, it prints the error and exits correctly, but for some reason TFS doesn't don't detect this and considers the step "done":
I'm not really sure what I'm missing, what does my PowerShell script/application need to do to indicate the the TFS that a failure has occurred? I thought the "PassThrough" tag in PowerShell should route the error code up, is that not correct?