I have a simple dotnet core application:
class Program
{
static int Main(string[] args)
{
try
{
throw new ArgumentException("Damn");
}
catch (Exception Ex)
{
Console.WriteLine(Ex.Message);
// Error
return 1;
}
// Success
return 0;
}
}
Return code is important as jobs are fired off from scheduler (Whether you use BMC control-m, autosys, rundeck, whatever). Scheduler will mark the job failed only if return code is 1 (Not zero). Otherwise you see errors from log but job status still flagged "Succeeded" (where it should be marked "Failed")
If we launch the job from PowerShell, we can use
dotnet HelloExceptionDotnetCore.dll
echo $LastExitCode
But can we do same with regular command prompt? Not Powershell?