0

I am currently transforming a config file in my project.

Debug config looks like:

<appSettings file="C:\MyPath\debug.config"></appSettings>

Release looks like this:

<appSettings  file="C:\MyPath\release.config"></appSettings>

My goal is to switch the file location depending on build profile.

I cannot find a way to transform the file value in the release version.

Reference to similar solution or documentation would be awesome.

King of the North
  • 393
  • 1
  • 5
  • 19
  • 1
    I guess you mean Release looks like this: ``, the xdt attributes should only be available in App.Config – vc 74 Mar 05 '18 at 11:37
  • Yeah! thanks for that. Updating the question. – King of the North Mar 05 '18 at 11:38
  • Transforming? How? XDT transform? Doesn't this only work on web.config? How does it work on app.config? Are you using a product that you failed to mention (such as slowcheetah)? – spender Mar 05 '18 at 11:41
  • Im pretty sure it works on web.config and app.config as well. This is why I mentioned config file – King of the North Mar 05 '18 at 11:43
  • Maybe something changed since I last did this. Packages like [this](https://marketplace.visualstudio.com/items?itemName=GolanAvraham.ConfigurationTransform) appear to support my proposition... I might be wrong. – spender Mar 05 '18 at 11:51
  • There are better different solutions for debug-release config transition. I think this question may help you. https://stackoverflow.com/questions/3788605/if-debug-vs-conditionaldebug – Ahmet Remzi EKMEKCI Mar 05 '18 at 11:53
  • @Spender: you can find some info [here](https://msdn.microsoft.com/en-us/library/kwybya3w.aspx) – King of the North Mar 05 '18 at 12:09
  • @Ahmet Thanks for this. But my codes works the same for every build profile I have. Only my configuration changes. And I believe its easier to maintain to store all configuration in the config file instead of hard coding them or something. Let me know if i misunderstood your answer – King of the North Mar 05 '18 at 12:12

1 Answers1

1

I found how its done:

I had to use xdt:Transform="SetAttributes(file)" in the App.Release.config

Like this:

<appSettings  file="C:\MyPath\release.config" xdt:Transform="SetAttributes(file)"></appSettings>

This will change only the file value

King of the North
  • 393
  • 1
  • 5
  • 19