AssemblyInfo.cs update version info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Author
heejune
commented
Sep 22, 2017
- setversion.py - Change the version info string inside the AssemblyInfo.cs file
- 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