initial checkin for VersionVDProj tools in tools dir
This commit is contained in:
parent
7a72dfc4a1
commit
1c3a646496
83
tools/w32/VersionVDProj/App.cs
Normal file
83
tools/w32/VersionVDProj/App.cs
Normal file
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 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
|
||||||
|
/// </summary>
|
||||||
|
class App
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[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 <PATH> version=<VERSION> [package=<PACKAGECODE>]" );
|
||||||
|
Console.WriteLine( "\t[product=<PRODUCTCODE>] [upgrade=<UPGRADECODE>]" );
|
||||||
|
Console.WriteLine( "The -msi switch is used for updating MSI installer projects" );
|
||||||
|
Console.WriteLine( "" );
|
||||||
|
Console.WriteLine( "<PATH> is the path to the vdproj file (without braces)" );
|
||||||
|
Console.WriteLine( "<VERSION> is the version to use in format #.#.# (without braces)" );
|
||||||
|
Console.WriteLine( "<PACKAGECODE> Optional package guid (if not specified will be auto-generated)" );
|
||||||
|
Console.WriteLine( "<PRODUCTCODE> Optional product guid (if not specified will be set to the" );
|
||||||
|
Console.WriteLine( "\tsame value used to set the package guid)" );
|
||||||
|
Console.WriteLine( "<UPGRADECODE> Optional upgrade guid (if not specified the upgrade code will" );
|
||||||
|
Console.WriteLine( "\tnot be modified)" );
|
||||||
|
Console.WriteLine( "" );
|
||||||
|
Console.WriteLine( "VersionVDProj -msm <PATH> version=<VERSION> [signature=<SIGNATURE>]" );
|
||||||
|
Console.WriteLine( "The -msm switch is used for updating merge module projects" );
|
||||||
|
Console.WriteLine( "" );
|
||||||
|
Console.WriteLine( "<PATH> is the path to the vdproj file (without braces)" );
|
||||||
|
Console.WriteLine( "<VERSION> is the version to use in format #.#.# (without braces)" );
|
||||||
|
Console.WriteLine( "<SIGNATURE> 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" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
tools/w32/VersionVDProj/App.ico
Normal file
BIN
tools/w32/VersionVDProj/App.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
60
tools/w32/VersionVDProj/ArgumentParser.cs
Normal file
60
tools/w32/VersionVDProj/ArgumentParser.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace VersionVDProj
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Summary description for ArgumentParser.
|
||||||
|
/// </summary>
|
||||||
|
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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
64
tools/w32/VersionVDProj/AssemblyInfo.cs
Normal file
64
tools/w32/VersionVDProj/AssemblyInfo.cs
Normal file
@ -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\<configuration>. 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("")]
|
71
tools/w32/VersionVDProj/MSIProjectVersioner.cs
Normal file
71
tools/w32/VersionVDProj/MSIProjectVersioner.cs
Normal file
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class that updates the version info of MSI projects
|
||||||
|
/// </summary>
|
||||||
|
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;
|
||||||
|
/// <summary>
|
||||||
|
/// createas a new instance of the class
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file">the project file</param>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
54
tools/w32/VersionVDProj/MSMProjectVersioner.cs
Normal file
54
tools/w32/VersionVDProj/MSMProjectVersioner.cs
Normal file
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class that updates the version info of merge module projects
|
||||||
|
/// </summary>
|
||||||
|
public class MSMProjectVersioner : VDProjectVersioner
|
||||||
|
{
|
||||||
|
private readonly static Guid MSM_PROJECT_TYPE = new Guid( "{DD7A5B58-C2F9-40FF-B2EF-0773356FB978}" );
|
||||||
|
|
||||||
|
private string signature;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// createas a new instance of the class
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file">the project file</param>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
tools/w32/VersionVDProj/README
Normal file
7
tools/w32/VersionVDProj/README
Normal file
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
BIN
tools/w32/VersionVDProj/bin/VersionVDProj.exe
Normal file
BIN
tools/w32/VersionVDProj/bin/VersionVDProj.exe
Normal file
Binary file not shown.
BIN
tools/w32/VersionVDProj/bin/VersionVDProj.pdb
Normal file
BIN
tools/w32/VersionVDProj/bin/VersionVDProj.pdb
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user