可以在csproj中进行文字处理吗?

时间:2019-05-16 06:17:39

标签: c# csproj

我的.csproj中有以下内容:

<ItemGroup>
  <Content Include="Main.qml" CopyToPublishDirectory="Always" />
</ItemGroup>

我需要在发布目录中的副本上的Main.qml中查找并替换一些文本。这可能吗?

2 个答案:

答案 0 :(得分:1)

MSBuild Extension Pack具有一个File类,该类接受TaskAction中的Replace。此操作可以执行正则表达式替换。

您将使用类似以下的方式:

<MSBuild.ExtensionPack.FileSystem.File TaskAction="Replace" RegexPattern="input*" Replacement="repl" Path="C:\$(ProjectDir)\$(PublishDir)\Main.qml"/>

答案 1 :(得分:0)

<postBuild>
    <Exec command="cmd command to find and replace on file:$(OutputPath)\Main.qml"/>
</PostBuild>