> Or, any other quick and dirty ways to modify a vbp file. I want to set the
> MajorVer, MinorVer and RevisionVer values.
For this specific task, we use a combination of a custom regex
function, and the loadfile, property and echo tasks.
The script:
<script language="C#" prefix="regex">
<code>
<imports>
<import namespace="System.Text.RegularExpressions"/>
</imports>
<![CDATA[
[Function("replace")]
public static string RegexReplace(string pSource,
string pSearch, string pReplace)
{
RegexOptions options = RegexOptions.IgnoreCase |
RegexOptions.Multiline;
Regex re = new Regex(pSearch, options);
return re.Replace(pSource, pReplace);
}
]]>
</code>
</script>
The nant target:
<target name="vb6versioning"
description="Set version information in VB6 applications."
failonerror="true" >
<loadfile file="${projectFileName}" property="project.file" />
<property name="ex" value="MajorVer *=
*[0-9]*[\r\n]*$" />
<property name="newvalue" value="MajorVer=${buildnumber.major}" />
<property name="project.file" value="${regex::replace(project.file,
ex, newvalue)}" />
<property name="ex" value="MinorVer *=
*[0-9]*[\r\n]*$" />
<property name="newvalue" value="MinorVer=${buildnumber.minor}" />
<property name="project.file" value="${regex::replace(project.file,
ex, newvalue)}" />
<property name="ex" value="RevisionVer *=
*[0-9]*[\r\n]*$" />
<property name="newvalue"
value="RevisionVer=${buildnumber.build}" />
<property name="project.file" value="${regex::replace(project.file,
ex, newvalue)}" />
<property name="ex" value="AutoIncrementVer *=
*[0-9]*[\r\n]*$" />
<property name="newvalue" value="AutoIncrementVer=0" />
<property name="project.file" value="${regex::replace(project.file,
ex, newvalue)}" />
<echo message="${project.file}" file="${projectFileName}" />
</target>
A bit brute force, but, it works for us.
Brad
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensign option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
NAnt-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nant-users