【问题标题】:Edit xml using regular expression in msbuild?在 msbuild 中使用正则表达式编辑 xml?
【发布时间】:2011-10-19 10:02:17
【问题描述】:

我正在使用 msbuild 脚本。我想在 msbuild 中使用正则表达式评论特定行。请帮我解决这个问题?请举一个例子,而不是使用正则表达式编辑版本

【问题讨论】:

    标签: msbuild msbuild-buildengine


    【解决方案1】:

    您可以使用 FileUpdate MSBuild Community Tasks:

    做到这一点

    文件更新
    使用正则表达式替换文件中的文本

    <ItemGroup>
       <FilesToBeUpdated Include="/Output/test.xml" />
    </ItemGroup>
    
    <FileUpdate
       Files="@(FilesToBeUpdated)"
       Regex="..."
       ReplacementText="..." />
    

    【讨论】:

    • 假设我有文件 test.xml 。然后我想在那个 xml 中注释行“如何 r u”。我如何使用 msbuild 实现这个?
    • @Nithin :您提供了有效的正则表达式这是我认为的另一个问题,不是 MSBuild 特定的
    猜你喜欢
    • 2020-05-24
    • 2018-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-19
    • 1970-01-01
    • 2014-09-05
    • 1970-01-01
    相关资源
    最近更新 更多