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.");
}
}
}
Update Revision
Thanks for this great tool! We did receive a lot of requests for this feature though, so InstallAware 2005 allows automatic change of the build code from command line builds:
Note that the one caveat for the above procedure is that the changed revision code does not update the project file...it just uses a new revision code for that build. So there might be cases wherein the UpdateRevision tool may come in handy! Many thanks.
Code: Select all
miabuild.exe ... /r
Note that the one caveat for the above procedure is that the changed revision code does not update the project file...it just uses a new revision code for that build. So there might be cases wherein the UpdateRevision tool may come in handy! Many thanks.
-
- Posts: 62
- Joined: Thu Mar 19, 2009 11:07 am
- Contact:
Great stuff for miabuild automation! Fixed for IA8
I tried this on a IA 8 project and it had a couple of bugs. Here is the corrected code:
[STAThread]
static void Main(string[] args)
{
if (args.Length < 1)
{
Console.WriteLine("Please specify a InstallAware project (.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 GUID).");
// The third one found is our revision in reality.
idx = text.IndexOf("{", idx + 1);
if (idx < 0)
throw new Exception("Invalid file (unknown revision).");
idx++;
string oldGuid = text.Substring(idx, 36);
string newGuid = Guid.NewGuid().ToString();
Console.WriteLine("Old Revision was: {0}", oldGuid);
Console.WriteLine("New Revision is: {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.");
}
I don't know what meaning that second GUID has, but the third one is the revision for sure. The other code always exceptioned out.
Perhaps the older version of IA had a different file layout?
[STAThread]
static void Main(string[] args)
{
if (args.Length < 1)
{
Console.WriteLine("Please specify a InstallAware project (.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 GUID).");
// The third one found is our revision in reality.
idx = text.IndexOf("{", idx + 1);
if (idx < 0)
throw new Exception("Invalid file (unknown revision).");
idx++;
string oldGuid = text.Substring(idx, 36);
string newGuid = Guid.NewGuid().ToString();
Console.WriteLine("Old Revision was: {0}", oldGuid);
Console.WriteLine("New Revision is: {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.");
}
I don't know what meaning that second GUID has, but the third one is the revision for sure. The other code always exceptioned out.
Perhaps the older version of IA had a different file layout?
Fiddling with technology
Return to “Plug-In Development”
Who is online
Users browsing this forum: No registered users and 47 guests