Select to view content in your preferred language

Build tool to auto-increment an ArcGIS Pro Add-In or Managed Configuration version

440
7
03-19-2025 03:01 PM
SelimDissem
Esri Contributor
4 7 440

This article shows 2 approaches to implement a tool to auto-increment the version number of your add-in.

Both approaches achieve the same result and your choice will mostly depend on preferences.

Executable based (C#) Solution

The attached Zip file, UpdateAddInVersion.zip, contains a Visual Studio 2022 solution with the source code for a tool that auto-increments your add-In's version number. This tool updates the last element of the version attribute in the config.daml file every time you build your project.

For example:

  • version="1.0" → version="1.1"
  • version="1.0.0" → version="1.0.1"

It is designed to work with Module Add-Ins and Managed Configuration that include a config.daml file.

Setup Instructions

Step 1: Download the attached Visual Studio solution Zip file (UpdateAddInVersion.zip)

Step 2: Unzip it somewhere convenient.

Step 3: Open the solution in Visual Studio 2022 and build it

Step 4: Copy all files from the build folder (bin\Debug\net8.0) into a sub directory of the Add-In you want processed. A good convention is to use a folder called BuildTools.

Step 5: Create a “Post-Build event” in your AddIn or Configuration project to run this tool to edit the version attribute in your add-in’s config.daml. Follow these steps to create the post build event:

  • Right click the Add-in or Configuration project in the Solution Explorer and select Properties in the context menu.
  • Expand the Build folder and select Events.
  • In the  “Post-Build event”  text box, invoke the UpdateAddInVersion.exe from its folder (step 4). In the screenshot below, “BuildTools\UpdateAddInVersion.exe” has been added to the Post-build event text box.
  • Visual Studio will now run this tool during the build. The version attribute in the config.daml will be incremented by the UpdateAddInVersion.exe.

SelimDissem_0-1743012858334.png

 

On a successful build, the post build call will auto-increment the last element of the version attribute in the config.daml: so version=”1.0” becomes version=”1.1” and version=”1.0.0” becomes version=”1.0.1”. It will update the last element of the version, no matter how many elements the version has.

Notes:

  1. The current source of the tool relies on it being in a subfolder of your add-in or configuration:

SelimDissem_1-1743012858334.png

 

  1. You can run it from anywhere as long as the path to the config.daml file is correct – you’ll see an error message or an exception in the Build Output of Visual Studio otherwise.
  2. The tool is a standalone .NET 8 executable with no other dependencies than .NET 8

MSBuild script solution

The attached AddInVersionTargets.zip file contains a MSBuild script to auto-increments your add-In's version number. By default, this tool updates the minor build number element of the version attribute in the config.daml file every time you build your project so version="1.0" becomes version="1.1".

Setup Instructions

Step 1: Download the attached AddInVersionTargets.zip file

Step 2: Unzip it somewhere convenient (i.e.: C:\BuildTools).

Step 3: Edit your Add-in project file to reference it: right-click on your add-in project and select Edit Project File in the context menu:

SelimDissem_2-1743012858334.png

 

At the bottom of the project file, right before the ArcGIS Pro SDK targets import statement, insert the following line:

<Import Project="C:\BuildTools\AddInVersion.targets"/>

 

SelimDissem_3-1743012858335.png

 

Notes:

  • As a result, your add-in will have its version tag in config.daml auto-incremented.
  • The script expects a version attribute in the form of major.minor.build.revision
  • By default, the script will update the minor element of the version (a.k.a. the 2nd digit)
  • The script can be changed to update any part of a version number as long as it exists in config.daml, by changing its (optional) IndexElement parameter:
    • revision for the 4th digit
    • build for the 3rd digit
    • minor for the 2nd digit
    • major for the 1st digit

This can be achieved by editing the AddInVersion.targets file to add an IndexElement parameter with the appropriate target element (revision in this example):

SelimDissem_4-1743012858335.png

 

  • As with the Visual Studio solution, the MSBuild script can be changed to adapt to your workflows and is provided as a sample of what can be done.
  • This implementation has no other dependency than Visual Studio 2022.
7 Comments
KrisCulin
Frequent Contributor

Is this now a requirement for add-ins and configurations?

We actually went a slightly different route and have a tool that modifies the GUID for our managed configuration.  The GUID uses the build of our product in it.  This way, every build that we do has a unique GUID assigned to it. 

But if it is a better idea to change the version in the config.daml file, we could look into that.

SelimDissem
Esri Contributor

@KrisCulin ,

there is no mandate or requirement to use this tool. We're just providing it to the community to use as they see fit. Definitely not designed to replace or override your workflow.

RichardDaniels
Honored Contributor

How about a simpler SDK tool that would automatically update the config.daml <date> tag during each 'Rebuild Solution' build? 

<Date>03/21/2025 11:00:00 AM</Date>

I would think the version attribute should be 3.0 for all ArcGIS Pro 3.x builds.

SelimDissem
Esri Contributor

@RichardDaniels ,

The source code is provided so you can definitely change it to fulfill your requirements.

As a reminder, the version attribute is the add-in version, not the version of Pro it targets (that's the desktopVersion attribute).

 

RichardDaniels
Honored Contributor

Thanks for the hint! I built a new console .exe that now updates my <Data> tag, it is run by the Visual Studio Prebuild even.

SelimDissem
Esri Contributor

@RichardDaniels ,

keep in mind that the pre-build event will execute even if the build fails, that's why we targeted the post build event to make updates to the config.daml (the updates are still included in the esriaddinx file that's generated).

RichardDaniels
Honored Contributor

Selim,

Since your update version tool is IN the post build event, then the Version # in the actual build will NOT contain that new number, rather it will be the version # of the last run. Post build is for such things as copying Solutions to an external location.

In my case, we need a new <date> for the build updated before VS Build executes.  ArcGIS Pro uses that date to determine if the AssemblyCache gets updated. If you never change the <date> then ArcGIS Pro will not automatically update the cache (i.e., you will have to manually delete it).

 

 

Contributors