Skip to main content

Notifications

Build pipeline error when generating packages

This is another tip to fix your build powershell scripts in order to reduce the number of errors you get when running a build pipeline.

Issue

Occasionally your build pipeline might have an error in the Generate Packages step.  It will not error out but will terminate partially successful.  The error would look like the following:

lcscapture.PNG

Cause

There is a folder - default: "C:\DynamicsSDK\VSOAgent\_work\1\Packages\Source", where the models are exported to during the build as its about to create the packages.  This export is done using modelutil.exe.

Modelutil will fail if it tries to export and a file already exists.

Fix

We will empty the folder prior to starting to put files in it.

Locate powershell file "GeneratePackages.ps1" in your c:\DynamicsSDK folder and edit it.

In line 196, prior to the foreach loop on models add the following:

        Write-Message "- Emptying model source folder..." -Diag
        Write-Message "Remove-Item `"$SourcePackageOutputPath\*`" -Recurse -Force" -Diag
        Remove-Item "$SourcePackageOutputPath\*" -Recurse -Force

Note: the \* is very important as without it it will delete the folder and not just the folder contents.


I hope this helps you.

Comments

*This post is locked for comments