Pregunta

sorry for such kind of question but I've spent too much time on it. I have an app.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <userSettings>
    <tbp.qa.Properties.Settings>
      <setting name="ServiceUri" serializeAs="String">
       <value>localhost</value>
     </setting>
   </tbp.qa.Properties.Settings>
 </userSettings>
</configuration>

How to change the 'value' with config transformation, I have tried the following and it doesn't change anything:

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <userSettings>
    <tbp.qa.Properties.Settings>
      <add name="ServiceUri" xdt:Transform="Replace" xdt:Locator="Match(name)">
        <value>localhost1</value>
      </add>
    </tbp.qa.Properties.Settings>
  </userSettings>
</configuration>

What am I doing wrong?

¿Fue útil?

Solución

Your config file transformation XML structure should match original config file's XML structure.

So in your config you have the element with the name setting but in your transformation file you have the element with the name add.

So change your transformation element from add to setting and it should work

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <userSettings>
    <tbp.qa.Properties.Settings>
      <setting name="ServiceUri" xdt:Transform="Replace" xdt:Locator="Match(name)">
        <value>localhost1</value>
      </setting>
    </tbp.qa.Properties.Settings>
  </userSettings>
</configuration>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top