CliGenerator.EXE Command line Error Code

Posts   
 
    
Rishi
User
Posts: 69
Joined: 31-Oct-2011
# Posted on: 10-Jan-2012 23:05:30   

Does CliGenerator command return any ErrorCode when its fail? (ERRORLEVEL) When i put this in batch file i want to stop when it fails.

Any idea?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 11-Jan-2012 05:33:26   

CliGenerator wont return any ERROR_LEVEL code. It will just write the log to the output file you indicate in the parameters, and if there is any exception it just will write it to the output.

However you can extend it. This is an example which just trap the exception and exits with an error code "1".

  1. Grab the SourceCode from the v3.1 additional downloads (Customer Area).
  2. Open the CliGenerator SourceCode and go to Startup.cs line 269. There is when the exception is caught.
  3. Write code to exit the application:
catch(Exception ex)
{
     GeneralUtils.DisplayException(ex);
     Environment.Exit(1);
}
  1. Compile and replace the executable in the LLBLGen installation folder.
  2. In your batch:
@echo off
"cligenerator.exe" "_LLBLGen Project\NW.LLBL.MSSQL.Adapter.v31.llblgenproj" .\out\ 1 output.txt
if errorlevel 1 (
   echo Something is wront. Error: %errorlevel%
   exit /b %errorlevel%
)

This is just some trivial example but you get the idea wink

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 11-Jan-2012 11:07:56   

Good idea to exit with a '1'. We'll add that to the todo list.

Frans Bouma | Lead developer LLBLGen Pro
Rishi
User
Posts: 69
Joined: 31-Oct-2011
# Posted on: 11-Jan-2012 15:59:48   

When do you think you can add this in your next update? I really don't like the way of changing source code.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 12-Jan-2012 12:16:11   

We've added this to v3.5's cli tools (not released yet)

It's really easy though, just change the void Main() method into int Main and return 1 instead of 0 when an exception occurs.

It's safe to change these tools' sourcecode as there are not much bug reports reported about them and as they're small, it's easy to diff the changes if they might occur. As v3.5 is still a month or so away before it goes into beta, you should make the changes to the current code. It's IMHO without risk, we don't expect a change in the current cli tools before v3.5. Just change the code a bit, compile the projects and use the .exe in your own situation. The v3.5 tools will have the mechanism so you can replace the custom ones you made with the ones we ship with v3.5

Frans Bouma | Lead developer LLBLGen Pro