3
我試圖通過對我的msbuild腳本中的文件執行一個正則表達式來替換Visual Studio安裝項目中的ProductName。要執行regEx替換,我試圖使用msbuild extension pack,特別是它的文件任務。我的MSBuild腳本內的目標看起來是這樣的:使用MSBuild.ExtensionPack.FileSystem.File替換vdproj
<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(或其他任何東西)的regex更新?
替換是不是太遲了,不會在.msi中結束? – reinierpost 2013-05-22 07:37:36