Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

1 Answer 1

up vote 5 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
2  
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! –  baens 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

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.