I am trying you change my default user configuration according to the build profile with slowCheetah, however I am not able to find the right way to use it
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="MyApp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<MyApp.Properties.Settings>
<setting name="Url" serializeAs="String">
<value>
something
</value>
</setting>
</MyApp.Properties.Settings>
</userSettings>
</configuration>
I have been trying
<!-- & it's an & escaped in xml-->
<add key="MyApp.Properties.Settings.Url" value="www.google.com" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
but it doesn't work.
How can I do this?
If I get it right, you have this:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="MyApp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<MyApp.Properties.Settings>
<setting name="Url" serializeAs="String">
<value>
something
</value>
</setting>
</MyApp.Properties.Settings>
</userSettings>
</configuration>
And you want to transform it to:
(replace <value>something</value>
with <value>www.google.com</value>
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="MyApp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<MyApp.Properties.Settings>
<setting name="Url" serializeAs="String">
<value>
www.google.com
</value>
</setting>
</MyApp.Properties.Settings>
</userSettings>
</configuration>
The easiest way to do this is to have the following text in your transformation file:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<userSettings>
<MyApp.Properties.Settings>
<setting name="Url" serializeAs="String">
<value xdt:Transform="Replace">
www.google.com
</value>
</setting>
</MyApp.Properties.Settings>
</userSettings>
</configuration>
It replaces (<value xdt:Transform="Replace">
) your <value></value>
with the text you want.
Or if you want to select the section to replace with the name="Url"
attribute:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<userSettings>
<MyApp.Properties.Settings>
<setting name="Url" serializeAs="String" xdt:Transform="Replace" xdt:Locator="Match(name)">
<value>
www.google.com
</value>
</setting>
</MyApp.Properties.Settings>
</userSettings>
</configuration>
We do the same action here (replace: xdt:Transform="Replace"
) but we reach the value to change by matching an attribute: xdt:Locator="Match(name)"
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