diff --git a/tools/w32/VersionVDProj/App.cs b/tools/w32/VersionVDProj/App.cs new file mode 100644 index 00000000..33fdc982 --- /dev/null +++ b/tools/w32/VersionVDProj/App.cs @@ -0,0 +1,83 @@ +// +// copyright 2003 Don Kackman - mailto:dkackman_2000@yahoo.com +// +// no warranty expressed or implied +// use however you'd like +// +using System; + +namespace VersionVDProj +{ + /// + /// This is the class that has the Main method. This class is responsible for parsing command line + /// arguments and dispatching them to the correct classes + /// + class App + { + /// + /// The main entry point for the application. + /// + [STAThread] + static int Main(string[] args) + { + if ( args.Length != 0 ) + { + try + { + ArgumentParser arguments = new ArgumentParser( args ); + VDProjectVersioner versioner = null; + + switch ( arguments.Command ) + { + case "msi": + versioner = new MSIProjectVersioner( arguments.ProjectFile ); + break; + case "msm": + versioner = new MSMProjectVersioner( arguments.ProjectFile ); + break; + default: + throw new Exception( string.Format( "Unrecognized command {0}", arguments.Command ) ); + } + + versioner.UpdateFile( arguments.Options ); + return 0; + } + catch ( Exception e ) + { + Console.WriteLine( "ERROR" ); + Console.WriteLine( e.Message ); + return 1; + } + } + + // with no arguments show the usage + ShowUsage(); + return 0; + } + + private static void ShowUsage() + { + Console.WriteLine( "VersionVDProj -msi version= [package=]" ); + Console.WriteLine( "\t[product=] [upgrade=]" ); + Console.WriteLine( "The -msi switch is used for updating MSI installer projects" ); + Console.WriteLine( "" ); + Console.WriteLine( " is the path to the vdproj file (without braces)" ); + Console.WriteLine( " is the version to use in format #.#.# (without braces)" ); + Console.WriteLine( " Optional package guid (if not specified will be auto-generated)" ); + Console.WriteLine( " Optional product guid (if not specified will be set to the" ); + Console.WriteLine( "\tsame value used to set the package guid)" ); + Console.WriteLine( " Optional upgrade guid (if not specified the upgrade code will" ); + Console.WriteLine( "\tnot be modified)" ); + Console.WriteLine( "" ); + Console.WriteLine( "VersionVDProj -msm version= [signature=]" ); + Console.WriteLine( "The -msm switch is used for updating merge module projects" ); + Console.WriteLine( "" ); + Console.WriteLine( " is the path to the vdproj file (without braces)" ); + Console.WriteLine( " is the version to use in format #.#.# (without braces)" ); + Console.WriteLine( " Optional unique id for the merge module (if not specified a guid" ); + Console.WriteLine( "\tbased signature will be auto-generated)" ); + Console.WriteLine( "" ); + Console.WriteLine( "Named arguments can be specified in any order" ); + } + } +} diff --git a/tools/w32/VersionVDProj/App.ico b/tools/w32/VersionVDProj/App.ico new file mode 100644 index 00000000..3a5525fd Binary files /dev/null and b/tools/w32/VersionVDProj/App.ico differ diff --git a/tools/w32/VersionVDProj/ArgumentParser.cs b/tools/w32/VersionVDProj/ArgumentParser.cs new file mode 100644 index 00000000..0c553fae --- /dev/null +++ b/tools/w32/VersionVDProj/ArgumentParser.cs @@ -0,0 +1,60 @@ +using System; +using System.IO; +using System.Collections; + +namespace VersionVDProj +{ + /// + /// Summary description for ArgumentParser. + /// + public class ArgumentParser + { + public readonly Hashtable Options; + public readonly string Command; + public readonly FileInfo ProjectFile; + + public ArgumentParser( string[] args ) + { + Options = new Hashtable(); + + if ( args.Length < 2 ) + throw new Exception( "Wrong number of arguments" ); + + Command = ParseCommand( args[0] ); + ProjectFile = ParseFileName( args[1] ); + + for ( int i = 2; i < args.Length; i++ ) + ParseArgument( args[i] ); + } + + private string ParseCommand( string command ) + { + if ( command.Substring( 0, 1 ) != "-" ) + throw new Exception( string.Format( "Unrecognized command {0}", command ) ); + + return command.Substring( 1 ).ToLower(); + } + + private FileInfo ParseFileName( string path ) + { + FileInfo file = new FileInfo( path ); + if ( !file.Exists ) + throw new Exception( string.Format( "The file {0} could not be found", path ) ); + + return file; + } + + private void ParseArgument( string arg ) + { + int eqPos = arg.IndexOf( '=', 0 ); + + if ( eqPos == -1 ) + throw new Exception( string.Format( "The argument {0} is not in the format NAME=VALUE", arg ) ); + + string name = arg.Substring( 0, eqPos ); + string val = arg.Substring( eqPos + 1 ); + + Options.Add( name.ToLower(), val ); + } + } +} diff --git a/tools/w32/VersionVDProj/AssemblyInfo.cs b/tools/w32/VersionVDProj/AssemblyInfo.cs new file mode 100644 index 00000000..5ee20efd --- /dev/null +++ b/tools/w32/VersionVDProj/AssemblyInfo.cs @@ -0,0 +1,64 @@ +// +// copyright 2003 Don Kackman - mailto:dkackman_2000@yahoo.com +// +// no warranty expressed or implied +// use however you'd like +// +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("Deployment Project Versioning Tool")] +[assembly: AssemblyDescription("Updates the version and guid of Visual Studio.Net deployment projects")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("2003 Don Kackman")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/tools/w32/VersionVDProj/MSIProjectVersioner.cs b/tools/w32/VersionVDProj/MSIProjectVersioner.cs new file mode 100644 index 00000000..a91f4a3b --- /dev/null +++ b/tools/w32/VersionVDProj/MSIProjectVersioner.cs @@ -0,0 +1,71 @@ +// +// copyright 2003 Don Kackman - mailto:dkackman_2000@yahoo.com +// +// no warranty expressed or implied +// use however you'd like +// +using System; +using System.IO; +using System.Collections; + +namespace VersionVDProj +{ + /// + /// Class that updates the version info of MSI projects + /// + public class MSIProjectVersioner : VDProjectVersioner + { + private readonly static Guid MSI_PROJECT_TYPE = new Guid( "{2C2AF0D9-9B47-4FE5-BEF2-169778172667}" ); + + private Guid productCode = Guid.Empty; + private Guid packageCode = Guid.Empty; + private Guid upgradeCode = Guid.Empty; + /// + /// createas a new instance of the class + /// + /// the project file + public MSIProjectVersioner( FileInfo file ) : base( file, MSI_PROJECT_TYPE ) + { + + } + + protected override void SetOptions( Hashtable options ) + { + // get the package code - generate if not specified + if ( options.Contains("packagecode") ) + packageCode = new Guid( options["packagecode"].ToString() ); + else + packageCode = Guid.NewGuid(); + + // get the product code - set to package code if not specified + if ( options.Contains("productcode") ) + productCode = new Guid( options["productcode"].ToString() ); + else + productCode = packageCode; + + // get the upgrade code - leave empty if not specified + if ( options.Contains("upgradecode") ) + upgradeCode = new Guid( options["upgradecode"].ToString() ); + } + + protected override string TranslateLine( string line ) + { + // look for the properties we are interested in changing + // if we find them, replace the old value with the new and return the new line string + // otherwise just return the line string + if ( line.IndexOf( "\"ProductVersion\"" ) != -1 ) + line = ReplaceValue( line, "ProductVersion", version.ThreePartVersion ); + + else if ( productCode != Guid.Empty && line.IndexOf( "\"ProductCode\"" ) != -1 ) + line = ReplaceValue( line, "ProductCode", "{" + productCode.ToString().ToUpper() + "}" ); + + else if ( packageCode != Guid.Empty && line.IndexOf( "\"PackageCode\"" ) != -1 ) + line = ReplaceValue( line, "PackageCode", "{" + packageCode.ToString().ToUpper() + "}" ); + + else if ( upgradeCode != Guid.Empty && line.IndexOf( "\"UpgradeCode\"" ) != -1 ) + line = ReplaceValue( line, "UpgradeCode", "{" + upgradeCode.ToString().ToUpper() + "}" ); + + return line; + } + } +} diff --git a/tools/w32/VersionVDProj/MSMProjectVersioner.cs b/tools/w32/VersionVDProj/MSMProjectVersioner.cs new file mode 100644 index 00000000..5c19d305 --- /dev/null +++ b/tools/w32/VersionVDProj/MSMProjectVersioner.cs @@ -0,0 +1,54 @@ +// +// copyright 2003 Don Kackman - mailto:dkackman_2000@yahoo.com +// +// no warranty expressed or implied +// use however you'd like +// +using System; +using System.IO; +using System.Collections; + +namespace VersionVDProj +{ + /// + /// Class that updates the version info of merge module projects + /// + public class MSMProjectVersioner : VDProjectVersioner + { + private readonly static Guid MSM_PROJECT_TYPE = new Guid( "{DD7A5B58-C2F9-40FF-B2EF-0773356FB978}" ); + + private string signature; + + /// + /// createas a new instance of the class + /// + /// the project file + public MSMProjectVersioner( FileInfo file ) : base( file, MSM_PROJECT_TYPE ) + { + } + + protected override void SetOptions( Hashtable options ) + { + // get the signature - generate if not specified + if ( options.Contains( "signature" ) ) + signature = options[signature].ToString(); + else + signature = "MergeModule." + Guid.NewGuid().ToString().ToUpper().Replace( "-", "" ); + } + + protected override string TranslateLine( string line ) + { + // look for the properties we are interested in changing + // if we find them, replace the old value with the new and return the new line string + // otherwise just return the line string + if ( line.IndexOf( "\"Version\"" ) != -1 ) + line = ReplaceValue( line, "Version", version.FourPartVersion ); + + // module signature cannot have dashes + else if ( line.IndexOf( "\"ModuleSignature\"" ) != -1 ) + line = ReplaceValue( line, "ModuleSignature", signature ); + + return line; + } + } +} diff --git a/tools/w32/VersionVDProj/README b/tools/w32/VersionVDProj/README new file mode 100644 index 00000000..cf1b5d1a --- /dev/null +++ b/tools/w32/VersionVDProj/README @@ -0,0 +1,7 @@ +This is a command line utility that update the version and GUID of VS.NET project files. There is no licese on this tool. + +The source is from +http://www.codeproject.com/dotnet/VersionVDProj.asp#xx1436860xx + + + diff --git a/tools/w32/VersionVDProj/bin/VersionVDProj.exe b/tools/w32/VersionVDProj/bin/VersionVDProj.exe new file mode 100644 index 00000000..b0ca6153 Binary files /dev/null and b/tools/w32/VersionVDProj/bin/VersionVDProj.exe differ diff --git a/tools/w32/VersionVDProj/bin/VersionVDProj.pdb b/tools/w32/VersionVDProj/bin/VersionVDProj.pdb new file mode 100644 index 00000000..105161d1 Binary files /dev/null and b/tools/w32/VersionVDProj/bin/VersionVDProj.pdb differ