我试图通过在我的 msbuild 脚本中对文件执行正则表达式来替换 Visual Studio 安装项目中保存的 ProductName。要进行正则表达式替换,我正在尝试使用msbuild 扩展包,特别是它的 File 任务。我的 msbuild 脚本中的目标如下所示:
<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>
当此目标运行时,我得到以下输出,但文件保持不变。
CustomiseMsi:
Processing File Collection
Processing File: C:\pathHere\mySetup.vdproj
我这样做对吗?有没有人以这种方式在 vdproj(或其他任何东西)上更新了正则表达式?