Wednesday, April 9, 2014

List compile errors using PowerShell

I always make sure that any compilations are logged. You do this by opening Tools, Options, Development, Compiler and check the "AOT log"-checkbox.
Having this on, whenever you compile anything, the operation and the result is logged. So for example if you initiate a full AOT compile in the client (not using AXBuild) there will be a text file named AOTComp.log normally in this folder:

C:\Users\YOUR_USERNAME\Microsoft\Dynamics AX\Log\

Interestingly, you can actually use this file to see how far the compilation has come using some text editor like Notepad++ and turning on "Update silently" and "Scroll to the last line after update" under Tools, Settings, Misc, File Status Auto-Detection. You can also install the "Document Monitor" plugin if that is your swag.

The PowerShell command to list any entries in the log that refers to an ERROR would be the following (example):

content 'C:\Users\tommy\Microsoft\Dynamics Ax\Log\AOTComp.log' | where {$_ -match "ERROR:"}

Now, you can do all sorts of things with the result, like ad-hoc checking or pushing it to a file, even a HTML-file.