using System; using System.Collections.Generic; using System.IO; namespace ProgramIncrimenter { static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main ( string [ ] args ) { for ( int i = 0; i < args.Length; i++ ) System.Diagnostics.Debug.Write ( args [ i ] ); string fileLocation = args [ 0 ] + "Properties\\AssemblyInfo.cs"; string [ ] Lines = File.ReadAllLines ( fileLocation ); int versionLineIndex = 0; int fileVersionLineIndex = 0; for ( int i = 0; i < Lines.Length; i++ ) { if ( Lines [ i ].Contains ( "AssemblyVersion" ) ) { versionLineIndex = i; } if ( Lines [ i ].Contains ( "AssemblyFileVersion" ) ) { fileVersionLineIndex = i; } } int majorVersion; int minorVersion; int buildNumber; int revision; // [assembly: AssemblyVersion ( "1.0.0.0" )] // [assembly: AssemblyFileVersion ( "1.0.0.0" )] string version = Lines [ versionLineIndex ].Split ( '"' ) [ 1 ]; System.Diagnostics.Debug.WriteLine ( version ); majorVersion = int.Parse ( version.Split ( '.' ) [ 0 ] ); minorVersion = int.Parse ( version.Split ( '.' ) [ 1 ] ); buildNumber = int.Parse ( version.Split ( '.' ) [ 2 ] ); revision = int.Parse ( version.Split ( '.' ) [ 3 ] ); buildNumber++; string newVersions = majorVersion + "." + minorVersion + "." + buildNumber + "." + revision; Lines [ versionLineIndex ] = "[assembly: AssemblyVersion ( \"" + newVersions + "\" )]"; Lines [ fileVersionLineIndex ] = "[assembly: AssemblyFileVersion ( \"" + newVersions + "\" )]"; File.WriteAllLines ( fileLocation, Lines ); } } }