[AX2012] AX32.exe command-line questions.

This question is answered

Hello,

1) If I run AX32.exe with the "synchronize" startupcmd, are there logs that are created that I can look at for information and errors? If so, where are they created. I tried running the command with the -logdir parameter and it didn't seem to create any logs in my specified location.

2) I'm trying to setup an automated build / sync script. I run the script through C# in a non-interactive session. When I try to just call the executable with parameters, it works (but it creates a client GUI window of course), but when I run in a non-interactive context it can't create the client GUI window and it seems like it doesn't do anything. Is there a way to run this executable non-interactively? I had read an article by Martin Drab (hello!) about AX32.exe and logging which seemed to suggest that my method of running the utility through C# would work, but apparently it doesn't.

Thanks.

Verified Answer
  • I'm not sure exactly what is going wrong without seeing code or any sort of output. But my build scripts for AX 2012 for TFS run the client executable non-interactively (they are workflow items that run from the TFS build service).

    You can find my source code on the DynamicsBuild project on codeplex: dynamicsaxbuild.codeplex.com

    All the workflow items are coded in C# and perform all functions needed for a build, including synchronize and others. Note how the later version of this code switched a bunch of things to using autorun.xml over the actual command-line arguments, as we found some disturbing inconsistencies in how some of the command-line options perform their task (not the same as manually running or running through autorun.xml).

  • If you use -startupcmd=synchronize, some information is logged to SysExceptionTable. Unfortunately the implementation is not great and errors are not logged, because they stop the whole process. You could simply catch synchronization errors and ignore them (in SysStartupCmdSynchronize class) - then the infolog messages will be logged to SysExceptionTable.

    Making any changes has one big disadvantage - you can't use such a solution in all situations, e.g. if you're building a clear AX environment. But when you choose the path of modifying AX, you can introduce any type of logging you want.

    Using startup commands always requires an AX client and there is no "normal" way how to hide the window (AFAIK). It's not usually the problem because the build runs in its own session (in TFS Build, as a scheduled task and so on). If you really need to do that, I have a hint for you - you can create a new (hidden) Windows desktop (see CreateDesktop) and run AX there. I experimented with it for one application (using its own GUI and secretly calling AX with a startup command) and it worked quite nicely.

All Replies
  • I'm not sure exactly what is going wrong without seeing code or any sort of output. But my build scripts for AX 2012 for TFS run the client executable non-interactively (they are workflow items that run from the TFS build service).

    You can find my source code on the DynamicsBuild project on codeplex: dynamicsaxbuild.codeplex.com

    All the workflow items are coded in C# and perform all functions needed for a build, including synchronize and others. Note how the later version of this code switched a bunch of things to using autorun.xml over the actual command-line arguments, as we found some disturbing inconsistencies in how some of the command-line options perform their task (not the same as manually running or running through autorun.xml).

  • If you use -startupcmd=synchronize, some information is logged to SysExceptionTable. Unfortunately the implementation is not great and errors are not logged, because they stop the whole process. You could simply catch synchronization errors and ignore them (in SysStartupCmdSynchronize class) - then the infolog messages will be logged to SysExceptionTable.

    Making any changes has one big disadvantage - you can't use such a solution in all situations, e.g. if you're building a clear AX environment. But when you choose the path of modifying AX, you can introduce any type of logging you want.

    Using startup commands always requires an AX client and there is no "normal" way how to hide the window (AFAIK). It's not usually the problem because the build runs in its own session (in TFS Build, as a scheduled task and so on). If you really need to do that, I have a hint for you - you can create a new (hidden) Windows desktop (see CreateDesktop) and run AX there. I experimented with it for one application (using its own GUI and secretly calling AX with a startup command) and it worked quite nicely.

  • You could take a look at the AutoRun startup command if it fits your requirements.

    msdn.microsoft.com/.../aa870082(v=ax.50).aspx

  • unfortunately i can't use the autorun startupcmd.

    Thanks Martin and Joris, that answered my question. I'm not building this for our in-house dynamics AX implementation, so I can't do too much "custom" stuff. I can't rely on users changing the x++ or anything like that. I'll just run this thing interactively, then. It seems my hands are tied.

    thanks again.