Search code examples
.netweb-configapp-configslowcheetah

Transform custom configuration setting using Slow Cheater


All examples of Slow Cheater seem to be focused on the app settings part of configuration files.

I'm curious to know if it's possible to achieve a similar output with a custom configuration setting.

E.g.

<MyConfigSection username="debug" password="d3bUg" />

Would transforms to

<MyConfigSection username="release" password="re1eas3" />

Edit I've found that xdt:Transform="Replace" will work in this example. But If I had other attributes that didn't change how would I achieve that without losing them from the config?

E.g.

<MyConfigSection username="debug" password="d3bUg" apiKey="12345" />
<MyConfigSection username="release" password="re1eas3" apiKey="12345" />

If I used

<MyConfigSection username="release" password="re1eas3" xdt:Transform="Replace" />

Then apiKey would disappear


Solution

  • This would only replace your attributes, retaining other parts in MyConfigSection

    <MyConfigSection username="release" password="re1eas3" xdt:Transform="SetAttributes(username, password)" />