2

I am working on an ASP.NET C# project, where I would like to make use of web.config transforms.

I therefor installed the extension "Configuration Transform" and added a Web.Debug.config and Web.Release.config.

Within the Web.config I have not declared anything specific to my application. The debug config contains my testing/developing settings while the release config contains tokens #{someVar}# that later will get replaced by TFS.

When I publish my application the Web.config gets correctly created according to the configuration (debug/release). Also Preview config transform gives the correct result (besides the line breaks).

However when starting the application from within Visual Studio 2017 with debug configuration it complains about missing tags.

Why is that and how can I fix this?

Web.config

<!-- Does not contain the request tag -->

Web.Debug.Config

<request xdt:Transform="Insert">
    <mysetting>MyDevelopmentSetting</mysetting>
</request>

Web.Release.config

<request xdt:Transform="Insert">
    <mysetting>#{MyTokenThatWillGetReplacedByTFS}#</mysetting>
</request>

1 Answer 1

1

Web config transforms do not run in Visual Studio (when you press F5/run the app in VS). They only run on builds when publishing.

Since your web.config doesn't have the setting and the application is expecting it, it's properly complaining about the missing tag.

You will need to add this tag to your web.config.

Sign up to request clarification or add additional context in comments.

7 Comments

Thanks for replying. I guess that this will make my web.debug.config obsolete as my debug/development settings will have to move up into the web.config
If you have a deployment to a dev server then debug might still make sense. The settings in your web.config could be to your local machine stuff. For example, a connection string to a local db. However, if you don't have that, then yes, your web.config could be your "dev/debug" settings and then you only have a release transform for production. :-)
Now... with that said. It is technically possible to get transforms to work on builds period but it creates more complexity and has downsides to it as well so if you really needed it, there are ways. I didn't offer any of them as your question was pretty straight forward with "Why isn't my transform running while debugging in VS". :-)
Have a look at this and the blog post in one of the answers.... stackoverflow.com/questions/35559289/…
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.