Friday, March 13, 2015

Generating cross reference data during the build process

This post applies to AX2012 R2. Cross reference data can be generated as part of the Full AOT compile process or via batch process. However the Full AOT compile with cross reference takes much longer than a normal R2 compile (which is already much slower than R3 axbuild), so I prefer to do this step after the nightly integration build has completed.

Method 1 - Full AOT compile

Set options as below, or use the following SQL to accomplish the same. Next perform a Full AOT compile, and the cross reference data will be updated.


Here's the SQL for setting the option above
Only bit 5 of column DebugInfo needs to be set for cross reference to work. The other bits are assigned to other settings:

use MicrosoftDynamicsAX

-- Substitute the ID of your build service account here
DECLARE @UserId VARCHAR(255) = 'admin'

-- VIEW STATUS OF CROSS REFERENCE
SELECT
 Debuginfo as CurrentDebugValue,
 (Debuginfo & 65519) AS DebugValue_CrossReferenceOff,
 (Debuginfo | 16) AS DebugValue_CrossReferenceOn,
 CASE WHEN (Debuginfo & 16) > 0 THEN 1 ELSE 0 END AS CrossReferenceStatus,
 * 
FROM USERINFO 
WHERE id = @UserId

-- TURN OFF CROSS REFERENCE
UPDATE USERINFO 
 SET Debuginfo = (Debuginfo & 65519)
 WHERE id = @UserId

-- TURN ON CROSS REFERENCE
UPDATE USERINFO 
 SET Debuginfo = (Debuginfo | 16)
 WHERE id = @UserId


Method 2 - Batch cross reference update

A small but important detail to consider: there must be a batch AOS running. It will suffice for the AOS performing Full AOT compile to be added to the default batch group. Otherwise, the cross reference window will spin eternally without making any progress.

Here's code which will do that via job:
// Run cross reference from AOT job
Args xrefArgs = new Args("SysCompileAll");
xRefUpdate::startxRef(xrefArgs.pack());


Exporting and importing with BCP

Note that cross reference data does NOT travel with the Modelstore database. Instead this data lives in the transactional side. You will need to export the cross reference data if you want to be able to import it to development environments or elsewhere. Here's one way to do that with the BCP utility provided with SQL:

bcp MicrosoftDynamicsAx.dbo.XREFTABLERELATION out "$TargetFolder\$($FilePrefix)XREFTABLERELATION.DAT" 
bcp MicrosoftDynamicsAx.dbo.XREFREFERENCES out "$TargetFolder\$($FilePrefix)XREFREFERENCES.DAT"    
bcp MicrosoftDynamicsAx.dbo.XREFNAMES out "$TargetFolder\$($FilePrefix)XREFNAMES.DAT"        
bcp MicrosoftDynamicsAx.dbo.XREFPATHS out "$TargetFolder\$($FilePrefix)XREFPATHS.DAT"        

No comments:

Post a Comment