tags:

views:

241

answers:

2

I am looking for an MSBuild task/script that will allow me to control the version of an old VB6 project?

The .vbp stores the version information as .ini style, but I cannot find a simple way to read and write the three entries.

A: 

I'm not sure that its implemented in any library

You could implement a custom task that calls GetPrivateProfileString.

However a novel idea would be to convert the file automatically to XML via an MSBUILD exec call and then parse that xml using the msbuild more easily.

Preet Sangha
I'm trying to avoid custom tasks as much as possible.
Rob Hunter
+2  A: 

I always use the FileUpdate-task from the MSBuildCommunityTasks, found on http://msbuildtasks.tigris.org/

You can use regular expressions to find the pattern and then replace in the text you want. For example: to replace the versionnumber in an assembly-info.cs:

<FileUpdate Files="@(VersioningAssemblyInfoFiles)"
                  Regex="AssemblyFileVersion\(&quot;.*&quot;\)\]"
                  ReplacementText="AssemblyFileVersion(&quot;$(VersionMajor).$(VersionMinor).$(VersionBuild).$(VersionRevision)&quot;)]" />
Bart Janson
+1 For being able to write, but it doesn't help for reading the version info.
Rob Hunter
Dude, research is teh friend! For reading from files, you can use <ReadLinesFromFile File="%(SolutionToBuild.Identity)"> <Output TaskParameter="Lines" ItemName="ItemsFromFile"/> </ReadLinesFromFile>and then filter out what you need using regular expressions, or, use the freely available XmlQuery-task (from the MSBuildCommunityTasks) if your document contains xml.
Bart Janson