GFlisch / Arc4u.Guidance.Doc

Other
5 stars 1 forks source link

MigrationTool execution failures are not propagated to the DevOps Release pipeline #219

Closed vvdb-architecture closed 5 months ago

vvdb-architecture commented 8 months ago

The code generated in Program.cs for a database migration tool declares the Main method as follows:

static void Main(string[] args)

and that method ends with:

        app.Execute(args);

A command is implemented to return 0 on success and -1 on failure:

        app.Command("...", config =>
        {
            config.Description = "...";
            config.OnExecute(() =>
            {
                try
                {
                    // whatever code here.
                    return 0;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    return -1;
                }
            });
        });

The DevOps release pipelines are coded in such a way that process return values different from 0 will cause the migration step to fail.

Unfortunately, this will never happen: because of the void Main declaration, the process always returns 0.

To fix this, you need to declare the Main method as follows:

static int Main(string[] args)

and the last line should just return the value of the command that has been applied:

return app.Execute(args);

Methinks this is a template issue.

GFlisch commented 8 months ago

Updated on the templating project. Will be part of the templating changes. Thanks.

vvdb-architecture commented 7 months ago

Confirmed fixed in ACC