Capture the exit-code from a console-app

95 Views Asked by At

Visual Build Professional (Pro, vbp) has "Success Exit Codes" where I can put in a whitelisted values...(when I define a call out to an external .exe)

When I create a call to an external .exe , how can I capture the return-code / exit-code and put it into a macro?

Basically, I'm trying to do in Visual Build Pro, what the below msbuild does.

Namely, capture the value of "ExitCode" to a property (macro in vbp language)...called MyExitErrorCode

<Target Name="ExecuteSomeEXETarget">
<Exec Command='"C:\Some.exe"' ContinueOnError='true'>
              <Output TaskParameter="ExitCode" PropertyName="MyExitErrorCode"/>
  </Exec>
  <Message Text="The exit code is $(MyExitErrorCode)"/>
  <Error Text="Error while executing Some EXE" Condition="'$(MyExitErrorCode)' > '0'" />

</Target>
1

There are 1 best solutions below

0
On

You can do a "Run Program"

In the "Command" put the path to your exe.

On the "More" tab, select the "Continue building" radio button.

..

Then you can capture the macro %RUNPROGRAM_EXITCODE%

..

For example, after your "Run Program" (step), Create a "Log Message" (step), and put this in

Hello '%RUNPROGRAM_EXITCODE%' !

.......

Not sure why the Macro doesn't show up in the list of global macros.

Now that I know the magic macro name, the documentation can be found

http://www.kinook.com/VisBuildPro/Manual/index.htm?visualbuild5_x.htm

• The build status of the Run Program action will always be a value from BuildStatusEnum and not the exit code of the process. The exit code is available in the RUNPROGRAM_EXITCODE temporary macro.

http://www.kinook.com/VisBuildPro/Manual/index.htm?runprogramaction.htm

The Run Program action creates a step to launch any external application, program, batch file, or command script. Visual Build starts and monitors the application, captures any output and logs it to the Output pane (and a log file if enabled), and terminates the application if the build is stopped.

When the step completes, the following temporary macros are created or updated: RUNPROGRAM_EXITCODE: If the Wait option is checked, the exit code of the process will be stored in this macro. RUNPROGRAM_PROCESSID: If the Wait option is unchecked, the process ID of the launched process will be stored in this macro.