在 vdproj 上使用 MSBuild.ExtensionPack.FileSystem.File Replace
我尝试通过对 msbuild 脚本中的文件执行正则表达式来替换 Visual Studio 安装项目中保存的 ProductName。要进行正则表达式替换,我尝试使用 msbuild 扩展包,特别是其文件任务。我的 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 (或其他任何东西)上更新正则表达式?
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 updated on a vdproj (or anything else) in this manner?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了同样的问题,在尝试了一些操作后,我得到了这个工作...
这将简单地将 ProductVersion 字符串替换为我在 Solution.DeploymentProject 变量中的版本。
我认为你根本不需要搞乱 CDATA。
I had this same issue and after trying a few things, I got this to work...
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.