Select to view content in your preferred language

ArcGIS Pro Custom Addin Version Number

681
4
07-26-2024 08:08 AM
trushar
Emerging Contributor

Hey there, everyone!

I am currently wondering a way to change the my custom addin version number. 
In the `Config.daml` file, see the `AddInInfo` tag, ArcGIS Pro reads this and displays.  

<AddInInfo id="{some-guid}" version="1.0.0" desktopVersion="3.0.36056"> ... </AddInInfo>

In our case, we have a CI/CD pipe line that assigns a new build number. AFAIK `Config.daml` is a static markup, changes have to be done prior to getting build started. So my question is how you all did it? Script it? Is there any Esri api/documentation that I should take a look first? Please share..
Thank you again,
Trushar

0 Kudos
4 Replies
tempStephenRhea_NV5
Frequent Contributor

Since the version element is just a string, you can format the value like below to make replacing it in CI/CD easier. We use Jenkins, so I have a stage to replace {buildNumber} with %BUILD_ID%, then a stage to build the add-in.

<AddInInfo id="{guid}" version="1.2.3.{buildNumber}" desktopVersion="2.9.32739">...</AddInInfo>

 Note: I haven't looked into this with Pro 3.x; there may be additional functionality to make it easier, but I think editing before building is still required.

DanNarsavage_IDWR
Frequent Contributor

Sorry to hijack this thread, but I'm trying to do exactly the same thing and struggling to figure out the Groovy necessary to update an attribute of an XML node.  Would you mind sharing that?

0 Kudos
RichardDaniels
Honored Contributor

Version number only uses 3 places (3.3.2), the 4th is ignored or, perhaps, throws an error.

0 Kudos
DanNarsavage_IDWR
Frequent Contributor

I've successfully placed build numbers there in Pro v3.3. Experimenting a bit more, I found that the "version" attribute of the "AddInInfo" node in Config.daml can be anything. Here's a screen grab of my working addin in Pro's "Add-In Manager" screen to illustrate . . .

DanNarsavage_IDWR_0-1736434937554.png

 

At any rate, here's the working Groovy function I ended up with in case it helps anyone later.  Note that Jenkins will make you approve EACH AND EVERY call to a Java method individually, so be prepared for that.

 

// Takes in the path to the Config.daml file that defines a Pro Addin
// Alters said file's 'AddInInfo' element with an updated 'version' attribute value
def updateAddinMetadata (String damlFilePath, String versionNumber, String environmentName) {
	// Parse the XML and retrieve the "AddInInfo" node
	def xml = readFile damlFilePath
	def arcGIS = new XmlParser().parseText(xml)
	def addinInfoNode = arcGIS.get("AddInInfo").get(0)
	
	// Set version number
	addinInfoNode['@version'] = versionNumber

	// Set build/release date
	dateNode = addinInfoNode.get("Date").get(0)
	dateNode.setValue(new Date().format("dd MMMMMMMMM yyyy"))

	// Set description text
	descriptionNode = addinInfoNode.get("Description").get(0)
	currentDescription = descriptionNode.text().trim()
	descriptionNode.setValue("Built for the ${environmentName} environment\n${currentDescription}")

	// Write the changes to Config.daml
	def writer = new FileWriter(damlFilePath)
	def nodePrinter = new XmlNodePrinter(new PrintWriter(writer))
	nodePrinter.setPreserveWhitespace(true) // without this, the Description & Date nodes are prettified--values placed on separate lines from tags. These newlines are rendered by ArcGIS Pro in the "Add-in Manager" screen and it looks awful
	nodePrinter.print(arcGIS)
	writer.close()
}

 

 

 

0 Kudos