简体   繁体   中英

Updating web.config with an MSBUILD task

I'm using an Web Deployment project to do a few post build tasks on a website I'm deploying.

I want to use a FileUpdate task to update my web.config and change the compilation mode from debug="true" to debug="false".

So, from this

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

To this

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

My FileUpdateTask looks like this

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

but that is completely invalid as you can't escape a quote in XML.

How else can I match the debug attribute in the Regex and have a valid ReplacementText value?

Cheers

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

Regex="debug=&quot;true&quot;"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM