I have numerous different Web.configs in my MVC 5 Application for different environments - e.g. Test/Prod
我的MVC 5应用程序中有许多不同的Web.config用于不同的环境 - 例如测试/生产
I have web transforms in place to change values for the different environments. So for example I have the following app setting in my web.config file:
我有适当的网络转换来更改不同环境的值。例如,我的web.config文件中有以下应用程序设置:
<appSettings>
<add key="DevDisplayPanel" value="true" />
</appSettings>
Then in my Web.Test.config and Web.Prod.config using a web transform to change the value as below:
然后在我的Web.Test.config和Web.Prod.config中使用Web转换来更改值,如下所示:
<appSettings>
<add key="DevDisplayPanel"
xdt:Transform="Replace"
xdt:Locator="Match(key)"
value="false" />
<appSettings>
However in my Web.config I also have my own custom section which is outside the <appSettings>
section and is as below:
但是在我的Web.config中,我也有自己的自定义部分,它位于
<myCustomSection>
<serverList>
<add zone="Zone1" url="https://dev-myurl1.com"/>
<add zone="Zone2" url="https://dev-myurl2.com"/>
<add zone="Zone2" url="https://dev-myurl3.com"/>
</serverList>
</myCustomSection>
My question is - is it possible to have a web transform so that for Test and Prod would look as below:
我的问题是 - 是否可以进行Web转换,以便Test和Prod看起来如下所示:
Test:
测试:
<myCustomSection>
<serverList>
<add zone="Zone1" url="https://test-myurl1.com"/>
<add zone="Zone2" url="https://test-myurl2.com"/>
<add zone="Zone2" url="https://test-myurl3.com"/>
</serverList>
</myCustomSection>
Prod:
PROD:
<myCustomSection>
<serverList>
<add zone="Zone1" url="https://prod-myurl1.com"/>
<add zone="Zone2" url="https://prod-myurl2.com"/>
<add zone="Zone2" url="https://prod-myurl3.com"/>
</serverList>
</myCustomSection>
1 个解决方案
#1
11
You can try replacing the contents of the <serverList>
tag.
您可以尝试替换
Test:
测试:
<myCustomSection>
<serverList xdt:Transform="Replace">
<add zone="Zone1" url="https://test-myurl1.com"/>
<add zone="Zone2" url="https://test-myurl2.com"/>
<add zone="Zone2" url="https://test-myurl3.com"/>
</serverList>
</myCustomSection>
Prod:
PROD:
<myCustomSection>
<serverList xdt:Transform="Replace">
<add zone="Zone1" url="https://prod-myurl1.com"/>
<add zone="Zone2" url="https://prod-myurl2.com"/>
<add zone="Zone2" url="https://prod-myurl3.com"/>
</serverList>
</myCustomSection>
#1
11
You can try replacing the contents of the <serverList>
tag.
您可以尝试替换
Test:
测试:
<myCustomSection>
<serverList xdt:Transform="Replace">
<add zone="Zone1" url="https://test-myurl1.com"/>
<add zone="Zone2" url="https://test-myurl2.com"/>
<add zone="Zone2" url="https://test-myurl3.com"/>
</serverList>
</myCustomSection>
Prod:
PROD:
<myCustomSection>
<serverList xdt:Transform="Replace">
<add zone="Zone1" url="https://prod-myurl1.com"/>
<add zone="Zone2" url="https://prod-myurl2.com"/>
<add zone="Zone2" url="https://prod-myurl3.com"/>
</serverList>
</myCustomSection>