Update Revision
Posted: Thu Mar 03, 2005 6:54 am
InstallAware has an option to update the revision on every build - unfortunately this does not work for commandline builds.
As a workaround I'm using this small tool:
http://www.camelot.co.at/files/dist/UpdateRevision.zip
Just call it with UpdateRevision.exe pathTo\\Project.mpr
Here's the source:
using System;
using System.IO;
using System.Text;
namespace UpdateRevision
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
if (args.Length<1)
{
Console.WriteLine("Specify a mpr file.");
return;
}
string name=args[0];
string text;
Console.WriteLine("Processing file {0}", name);
using (StreamReader input=new StreamReader(name, Encoding.ASCII))
text=input.ReadToEnd();
int idx=text.IndexOf("{"); // product code
if (idx<0) throw new Exception("Invalid file (no product).");
idx=text.IndexOf("{", idx+1); // revision code
if (idx<0) throw new Exception("Invalid file (no revision).");
if (text.IndexOf("{", idx+1)>=0) throw new Exception("Invalid file (unknown guid).");
idx++;
string oldGuid=text.Substring(idx, 36), newGuid=Guid.NewGuid().ToString();
Console.WriteLine("Old Revision: {0}", oldGuid);
Console.WriteLine("New Revision: {0}", newGuid);
string text2=text.Substring(0, idx);
text2+=newGuid;
text2+=text.Substring(idx+36);
File.Copy(name, name+".revbak", true);
using (StreamWriter output=new StreamWriter(name, false, Encoding.ASCII))
output.Write(text2);
Console.WriteLine("done.");
}
}
}
As a workaround I'm using this small tool:
http://www.camelot.co.at/files/dist/UpdateRevision.zip
Just call it with UpdateRevision.exe pathTo\\Project.mpr
Here's the source:
using System;
using System.IO;
using System.Text;
namespace UpdateRevision
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
if (args.Length<1)
{
Console.WriteLine("Specify a mpr file.");
return;
}
string name=args[0];
string text;
Console.WriteLine("Processing file {0}", name);
using (StreamReader input=new StreamReader(name, Encoding.ASCII))
text=input.ReadToEnd();
int idx=text.IndexOf("{"); // product code
if (idx<0) throw new Exception("Invalid file (no product).");
idx=text.IndexOf("{", idx+1); // revision code
if (idx<0) throw new Exception("Invalid file (no revision).");
if (text.IndexOf("{", idx+1)>=0) throw new Exception("Invalid file (unknown guid).");
idx++;
string oldGuid=text.Substring(idx, 36), newGuid=Guid.NewGuid().ToString();
Console.WriteLine("Old Revision: {0}", oldGuid);
Console.WriteLine("New Revision: {0}", newGuid);
string text2=text.Substring(0, idx);
text2+=newGuid;
text2+=text.Substring(idx+36);
File.Copy(name, name+".revbak", true);
using (StreamWriter output=new StreamWriter(name, false, Encoding.ASCII))
output.Write(text2);
Console.WriteLine("done.");
}
}
}