Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AssemblyInfo.cs update version info
def set_package_version(manifest_file, target_version):
from xml.etree import ElementTree as et
et.register_namespace("", "http://schemas.microsoft.com/appx/manifest/foundation/windows10")
et.register_namespace("mp","http://schemas.microsoft.com/appx/2014/phone/manifest")
et.register_namespace("uap", "http://schemas.microsoft.com/appx/manifest/uap/windows10")
tree = et.parse(manifest_file)
e = tree.find('{http://schemas.microsoft.com/appx/manifest/foundation/windows10}Identity')
e.attrib['Version'] = target_version
tree.write(manifest_file, xml_declaration=True, encoding='utf-8')
import re
import sys
def set_version(infocs, target_version):
if not infocs or not target_version:
raise Exception('invalid param')
return
with open(infocs, "r+") as f:
assemblyinfo_cs = f.read()
pattern_1 = re.compile(r'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', re.MULTILINE)
pattern_2 = re.compile(r'AssemblyFileVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', re.MULTILINE)
sub1 = r'AssemblyVersion("{}")'.format(target_version)
sub2 = r'AssemblyFileVersion("{}")'.format(target_version)
phase_1 = re.sub(pattern_1, sub1, assemblyinfo_cs)
phase_2 = re.sub(pattern_2, sub2, phase_1)
f.seek(0)
f.write(phase_2)
f.truncate()
@heejune

This comment has been minimized.

Copy link
Owner Author

@heejune heejune commented Sep 22, 2017

  1. setversion.py - Change the version info string inside the AssemblyInfo.cs file
  2. set_package_version.py - Change the version of the deployment package, which is located in Package.appxmanifest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.