Tuesday, October 31, 2017

PSA: AX7 Build Failure on Generate Packages / Model Export

More and more customers are seeing an error in the "Generate Packages" build step on their AX7 automated builds. The build shows as "Partially Succeeded" and the step that generates packages shows a problem.
The following error is shown in the build summary:

Error generating deployable packages: Error:
Unexpected exit code from model export: 1
At C:\DynamicsSDK\GeneratePackage.ps1:523 char:5

And going into the logs, the following details are shown:

- Foundation Upgrade: Exporting model source...
- Command: J:\AosService\PackagesLocalDirectory\Bin\ModelUtil.exe -export -metadatastorepath="J:\AosService\PackagesLocalDirectory" -modelname="Foundation Upgrade" -outputpath="C:\DynamicsSDK\VSOAgent\_work\1\Packages\Source"
Model Foundation Upgrade was not found in the specified Metadata Store
- Foundation Upgrade: Model export completed with exit code: 1
- Exception thrown at C:\DynamicsSDK\GeneratePackage.ps1:216: throw "Error: Unexpected exit code from model export: $ModelUtilExitCode"
System.Management.Automation.RuntimeException: Error: Unexpected exit code from model export: 1
Error generating deployable packages: Error: Unexpected exit code from model export: 1 At C:\DynamicsSDK\GeneratePackage.ps1:523 char:5

The automated build has an optional (turned on by default) to not just create the deployable package but also produce an export of all the models it built. The way this is done is it looks at any descriptor files for any models in source control, and those are the ones being exported (since those are also models for which their containing package are built).
That said, it appears many customers add the whole Descriptor folder to source control when over-layering existing packages. In itself this doesn't matter since the only extra work this creates is the model exports, it doesn't add any extra compile time since any one of the descriptors would cause the whole package to recompile.

The problem lies in the "Foundation Upgrade" model. This is an old artifact and this model is actually "Disabled" (a flag in the descriptor file). As such, our metadata APIs ignore this model - you will notice even though the descriptor and model are in your packages folder, this model is not showing up in the AOT. So, when the build tries to export this model, the model utility asks the metadata API for the model, and the API says it doesn't exist...

The fix of course is easy. The build scripts will be updated to double check the flag and not try to export disabled models. For customers or partners running into this issue today the answer is also easy - just remove the "foundation upgrade.xml" file from your source control. Note that this will trigger the deletion of that file on any dev boxes as well, but that is not an issue since this model isn't loaded or used anyway. A conversation has also started to see if this model should be downright removed in the next application release.

Saturday, October 21, 2017

Cross-Post: Pointing Build Definitions To Specific VMs (agents)

Dear readership,

Having a personal blog but also having opportunities to write on official blogs and documentation has its pros and cons. As I now have ownership of the AX Dev ALM blog on MSDN I will have the challenge of deciding when to post where regarding ALM related topics. I realize many people read this blog for some of the ALM related topics, so I figured I would cross-post here. I encourage you to follow the AxDevALM blog directly as it's not my intention to keep cross-posting everything. Perhaps some PSA stuff on the official blog and in-depth or example stuff here, we'll see.

For now, here's the link: Pointing Build Definitions To Specific VMs (agents).

And yes, I realize we're missing a lot of documentation on docs.microsoft.com regarding the build process. Posting there is a much lengthier and more stringent process, and blogging is just an easy, quick way to put something out there. The ALM blog is quick and painless, but it's official. Here, I can say (almost) anything I want :-)

I am working on other blog posts (on both blogs) so keep an eye out for those!