web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

AXBuild.exe xppcompileall - AxCompileAll.html to e-mail or alert if Errors <> 0

(0) ShareShare
ReportReport
Posted on by

Hello,

I'm currently working at a customer with lots and lots of DEV-machines connected to TFS.

I would like to scheduled following:

1. run AXBuild.exe with batch (or powershell) every night/week

2. If the AxCompileAll.html contains Errors <> 0 send e-mail.

The html file contains this if all is OK:

Compiler Error log : 2016-02-12

Errors : 0

Warnings : 0

Best Practice Deviations : 0

If errors:

Compiler Error log : 2016-02-18

Errors : 13

Warnings : 24

Best Practice Deviations : 0

 

The first step is easy. To send the AxCompileAll.html via e-mail etc with powershell is also doable.

BUT..my issue is that i need to filter out to only do actions if Errors <> 0.

Anyone have any solution for this or input?

If there is a way with Select-String to filter out this it would be the best solution I think. Tried that but have not found a way to do above yet.

This is my current ps script for this:

compile:
$ServerInstallDirectory = "C:\Program Files\Microsoft Dynamics AX\60\Server\DynamicsAX_STAGE"
& $ServerInstallDirectory\bin\axutil.exe schema
$ClientInstallDirectory = "C:\Program Files (x86)\Microsoft Dynamics AX\60\Client"
& $ServerInstallDirectory\bin\AXBuild.exe xppcompileall /aos=01 /workers=12 /nocleanup /altbin=$ClientInstallDirectory\Bin /compiler=$ServerInstallDirectory\bin\ax32serv.exe
$TargetFile = $ServerInstallDirectory + "\Log\AxCompileAll.html"

send e-mail:

$fromaddress = donotreply@mailserver.com
$toaddress = "Alert@customer.com"
#$bccaddress = ""
#$CCaddress = ""
$Subject = "Compile - Stage - Results"
$body = get-content .\content.htm
$attachment = "C:\Program Files\Microsoft Dynamics AX\60\Server\DynamicsAX_STAGE\Log\AxCompileAll.html"
$smtpserver = "mailserver"

####################################

if( (get-item "C:\Program Files\Microsoft Dynamics AX\60\Server\DynamicsAX_STAGE\Log\AxCompileAll.html").length -gt 105KB)
{
    $message = new-object System.Net.Mail.MailMessage
 $message.From = $fromaddress
 $message.To.Add($toaddress)
 #$message.CC.Add($CCaddress)
 #$message.Bcc.Add($bccaddress)
 $message.IsBodyHtml = $True
 $message.Subject = $Subject
 $attach = new-object Net.Mail.Attachment($attachment)
 $message.Attachments.Add($attach)
 $message.body = $body
 $smtp = new-object Net.Mail.SmtpClient($smtpserver)
 $smtp.Send($message)
}

(the length -gt 105KB is one way i use today to see what file size is the break even when the Error occur. In my case 105KB means 0 Errors. If Errors=3 the file size will be like 135kb)

BR

Peter Liliegren

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Iulian Cordobin Profile Picture
    8,201 on at

    I believe what you want is to take a look at this: gallery.technet.microsoft.com/.../Build-and-deploy-for-b166c6e4.These are the Microsoft standard build scripts. You can find all you need in there.

  • Verified answer
    Iulian Cordobin Profile Picture
    8,201 on at

    Snippet from the Common.ps1:

    function Check-CompilerErrors

    {

       Write-InfoLog ("Begin Check-CompilerErrors: {0}" -f (Get-Date))

       $compileErrors = $false

    if ((test-Path (join-path $clientLogDir "AxCompileAll.html")) -eq $true)

    {

    foreach ($line in (Get-Content (join-path $clientLogDir "AxCompileAll.html")))

    {

    if (($XMLstarted -eq $true) -and ($line.Contains('</XML>')))

    {

    $XMLstarted = $false

    $xmlContent += $line.Replace('</XML>','')

    }

    if ($XMLstarted -eq $true) {$xmlContent += $line}

    if ($line -eq '<XML ID="compilerinfo">') {$XMLstarted = $true}

    }

    [xml]$AxXml = $xmlcontent

    foreach($record in $axXml.AxaptaCompilerOutput.Record)

    {

    if ($record -ne $null -and (($record.field[7]).get_InnerText()) -eq "0")

    {

                   $compileErrors = $true

    $line = "Compiler ERROR: {0}\{1} : {2}" -f ($record.field[0]).get_InnerText(),($record.field[6]).get_InnerText(),($record.field[10]).get_InnerText()

    Write-ErrorLog($line)

    }

    }

    }

       if ($compileErrors -eq $true)

       {

           Write-ErrorLog "Errors while compiling code."

       }

       Write-InfoLog ("End Check-CompilerErrors: {0}" -f (Get-Date))

    }

  • Community Member Profile Picture
    on at

    Thanks a lot. This will surely solve my issue

  • Community Member Profile Picture
    on at

    Hi ,

    Try changing:

    html").length -gt 105KB)

    to:

    html").length -gt 105)

  • Suggested answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    Do you have any reason not to use Team Foundation Build? If you're using TFS for version control, why not for builds? You're writing scripts for things that Team Foundation Build can already do for you, which doesn't sounds very efficient.

    There are even AX build activities for XAML-based builds, which (among other things) do all the parsing of errors for you, therefore you wouldn't have to worry about it if you used them. You'll find them in CodePlex project called Dynamics AX Admin Utilities.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans