Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I don't think there is an out-of-the-esri-box way to do this, but has anyone hacked up a way to change this value automatically for a build? Perhaps using a pre-build event command?

share|improve this question
    
+1! Date would be good too. – blah238 Oct 6 '11 at 22:27
1  
How about using some Python in the pre-build event to edit the XML directly? – Chad Cooper Oct 6 '11 at 23:16
    
@ChadCooper: I ended up going that route. I was really hoping someone would have already written it. – Jay Cummins Oct 7 '11 at 12:39
up vote 7 down vote accepted

The Python option works for me:

c:\Python26\ArcGIS10.0\python.exe C:\sandbox\py\misc\UpdateAddInVersionNumber.py "$(ProjectDir)Config.esriaddinx"

enter image description here

(Python gurus, feel free to jump in and make it better) UpdateAddInVersionNumber.py:

import os, sys
import xml.dom.minidom
import datetime

filename = sys.argv[1]
print filename

b = 0

doc = xml.dom.minidom.parse(filename)

tags = doc.getElementsByTagName('Version')

if (len(tags)==1):
    currentNodeValue =  tags[0].childNodes[0].toxml()
    tokens = currentNodeValue.split('.')
    lastToken = tokens[len(tokens) -1]
    if lastToken.isnumeric():
        i = int(lastToken)
        i +=1       
        tokens[len(tokens) -1] = str(i)
        newVersionNumberValue='.'.join(tokens)
        tags[0].childNodes[0].nodeValue = newVersionNumberValue
        b = 1
        print newVersionNumberValue


tags = doc.getElementsByTagName('Date')
if (len(tags)==1):
    tags[0].childNodes[0].nodeValue =datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
    b = 1
    print tags[0].childNodes[0].nodeValue

if (b==1):
    f = open(filename,'wb')
    doc.writexml(f,encoding= 'utf-8')
    f.close()

sys.exit()
share|improve this answer
3  
You should get extra points for having to roll this yourself! – Chad Cooper Oct 7 '11 at 13:38
    
Heck of a lot better then my method! I've installed cygwin with sed that does roughly the same thing. Kudos! – Erik L Oct 7 '11 at 16:33
    
@baens: that's what I attempted initially, but I'm terrible with sed/ssed! – Jay Cummins Oct 8 '11 at 15:50

A second approach using a utility exe (requires .NET 4) that I've recently extended:

esri_addin_util.exe -o UpdateProperties --updateDate --addinDesc="Test Description ABC" --increaseVersion -f "Path to the Directory containing the esriaddinx file"

https://s3.amazonaws.com/cumminsjp/misc/esri_addin_util.zip

  -o/--operation required option is missing.


  -f, --file           Add In File

  -o, --operation      Required. Operation: ShowAddInVersion, PurgeAddIns,
                       Diag, ZipAddIn, UpdateProperties

  --output             Output file

  --updateDate         (Default: True) Updates the Date property of the AddIn
                       to the current UTC date when performing a '-o
                       UpdateProperties' operation.

  --addinDesc          Updates the AddIn Description.

  --increaseVersion    (Default: True) Increases the version number of the
                       AddIn when performing a '-o UpdateProperties' operation.

  --help               Display this help screen.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.