开发者

Read and edit an .ini file with MSBuild

开发者_C百科

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.


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;)]" />


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜