1

我正在使用 Web 部署项目在我正在部署的网站上执行一些后期构建任务。

我想使用 FileUpdate 任务来更新我的 web.config 并将编译模式从更改debug="true"debug="false".

所以,从这

<compilation defaultLanguage="c#"
                 debug="true" />

对此

<compilation defaultLanguage="c#"
                 debug="false" />

我的 FileUpdateTask 看起来像这样

<FileUpdate Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU'"
                Files="$(Configuration)\Web.Config"
                Regex="debug=\"true\""
                ReplacementText="debug=\"false\"" />

但这完全无效,因为您无法在 XML 中转义引号。

我还能如何匹配正则表达式中的调试属性并具有有效的 ReplacementText 值?

干杯

4

1 回答 1

5

要么使用MSBuild 社区任务中的 XmlUpdate 任务,要么尝试以下正则表达式:

Regex="debug=&quot;true&quot;"
于 2009-12-18T12:10:52.890 回答