Created
July 17, 2012 20:03
-
-
Save jgeurts/3131675 to your computer and use it in GitHub Desktop.
Update android version strings
This file contains hidden or 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
using System.IO; | |
using System.Text.RegularExpressions; | |
namespace AndroidAutoIncrementVersion | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
try | |
{ | |
string file = @"AndroidManifest.xml"; | |
string text = File.ReadAllText(file); | |
Regex regex = new Regex(@"(?<A>android:versionCode="")(?<VER>\d+)(?<B>"")", RegexOptions.IgnoreCase); | |
Match match = regex.Match(text); | |
int verCode = int.Parse(match.Groups["VER"].Value) + 1; | |
text = regex.Replace(text, "${A}" + verCode + "${B}", 1); | |
Regex regex1 = new Regex(@"(?<A>android:versionName=""\d+\.\d+\.)(?<VER>\d+)(?<B>"")", RegexOptions.IgnoreCase); | |
Match match1 = regex1.Match(text); | |
int verCode1 = int.Parse(match1.Groups["VER"].Value) + 1; | |
text = regex1.Replace(text, "${A}" + verCode1 + "${B}", 1); | |
File.WriteAllText(file, text); | |
} | |
catch {} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment