I am trying to make different config files for different cases (debug,release, etc.) and I would like to change some settings for different builds.
<configuration>
<applicationSettings>
<Program1.Properties.Settings>
<setting name="CustomerId" serializeAs="String">
<value>Custormer1-13256</value>
</setting>
</Program1.Properties.Settings>
</applicationSettings>
</configuration>
How can I change the value inside the tag to something else?
ex. <value>Customer2-343242</value>
If you have a web application project, Right-click on web. config and choose Add Config Transform. This will add any config transforms that are missing from your project based on build configurations (i.e. if you have Production and Staging build configs, both will get a transform added).
The xdt:Transform attribute value "SetAttributes" indicates that the purpose of this transform is to change attribute values of an existing element in the Web. config file.
If you are using the extension Configuration Transform go to Build > Configuration Manager and find the Configuration dropdown for the project of which you want to change the app config. You can then select the edit and rename the build configurations for that project.
Add xdt:Locator="Match(name)"
to Erwin's answer
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<applicationSettings>
<Program1.Properties.Settings>
<setting name="CustomerId" serializeAs="String" xdt:Transform="Replace"
xdt:Locator="Match(name)">
<value>Customer2-343242</value>
</setting>
</Program1.Properties.Settings>
</applicationSettings>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With