开发者

using MSBuild.ExtensionPack.FileSystem.File Replace on vdproj

Im trying to replace the ProductName held inside a Visual Studio setup project by performing a regex on the file in my msbuild script. To do the regEx replacement Im trying to use msbuild extension pack and in particular its File task. The target inside my msbuild script looks like this:

<Target Name="CustomiseMsi">
<PropertyGroup>
  <RegExPattern>
    <![CDATA[(?:\""ProductName\"" = \""8:.*)]]>
  </RegExPattern>
  <RegExReplacement>
    <![CDATA["\"ProductName\" = \"8:MyApp v1.0\""]]>
  </RegExReplacement>
  <RegExOutput></RegExOutput>
</PropertyGroup>

<MSBuild.ExtensionPack.FileSystem.File
  TaskAction="Replace"
  RegexPattern="$(RegExPattern)"
  Replacement="$(RegExReplacement)"
  Files="@(AbsolutePathToVdProjToParse)">
</MSBuild.ExtensionPack.FileSystem.File></Target>

When this target runs I get the following output, but the file remains unchanged.

CustomiseMsi:
  Processing File Collection
Processing File: C:\pathHere\mySetup.vdproj

Am I going about this right way? Has anyone done regex upda开发者_开发问答ted on a vdproj (or anything else) in this manner?


I had this same issue and after trying a few things, I got this to work...

<MSBuild.ExtensionPack.FileSystem.File TaskAction="Replace" 
    TextEncoding="ASCII"  RegexPattern='"ProductVersion" = "8:.*"' 
    Replacement='"ProductVersion" = "8:$(Version)"' 
    Files="%(Solution.DeploymentProject)"/>

This will simply replace the ProductVersion string with the version that I have in my Solution.DeploymentProject variable.

I dont believe you need to mess with CDATA at all.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜