Delphi: keep the file version build number set to the current SVN revision number
2007-04-02 23:04 i1184 [permalink]
If I'd known it could be this simple! Should have used this long before.
Use this script to change the build number of the file version to the current SVN revision you've got checked out. Optionally adapt this script to do more projects, and even the product version, and add it on top of a ProjectGroupif
(WScript.Arguments.length==0){
WScript.Echo(
"Usage UpdSvnRev.js <ProjectName> [<SvnDir>]");}
else
{
var ProjectName=WScript.Arguments(0);var SvnDir=WScript.Arguments.length>=2?WScript.Arguments(1):".";ProjectName=ProjectName.replace(
new RegExp("\\.dpr$",""),"");var fso=new ActiveXObject("Scripting.FileSystemObject");var f1=fso.FileExists(SvnDir+"\\_svn\\entries.")?fso.OpenTextFile(SvnDir+
"\\_svn\\entries."):fso.OpenTextFile(SvnDir+
"\\.svn\\entries.");f1.SkipLine();
f1.SkipLine();
f1.SkipLine();
var rev=f1.ReadLine();f1.Close();
f1=fso.OpenTextFile(ProjectName+
".dof");var fcon=f1.ReadAll();f1.Close();
fcon=fcon.replace(
new RegExp("^(Build)=[0-9]+?$","m"),"$1="+rev);fcon=fcon.replace(
new RegExp("^(FileVersion=[0-9]+?\\.[0-9]+?\\.[0-9]+?)\\.[0-9]+?$","m"),"$1."+rev);f1=fso.CreateTextFile(ProjectName+
".dof",1,0);f1.Write(fcon);
f1.Close();
}