简体   繁体   中英

visual studio 2010 - debug using “release” web.config transform?

I never really understood this. I understand that the configuration settings are for publishing, but can they be used for debugging?

Meaning, we have various transforms for our web.config (local, staging, and production environments and DB settings). Why can't I debug (trace through) my website project running locally, but using configuration from my other config transforms? Is this possible? Thank you.

Currently the Web.config transforms are only applied during the Web Publish Pipleline (WPP), not during build. The intention is that developers can muck with web.config to fit their local needs, but the transforms are applied during publishing to ensure a consistent configuration.

If you're interested in hacking your project to make the transformation happen on build, check out this link .

I think the 'debug' configuration is not available with transformed configs. If you want to use debugging, you need to have it set to use the debug config association not a transformed configuration.

I have the same problem and have can only debug when the configuration is set to Debug and not release even though I have multiple types of transformed config files.

It's two different types of compiles, Release has very different information compiled into the applciation than Debug. So when you choose to compile as Release, that debug info is not even there. You need to attach release configuration and attach that to the Debug compile if you want to be able to debug it.

See this post from Scott Gu which explains a lot of the differences between 'Release' vs 'Debug' compiles:

http://weblogs.asp.net/scottgu/archive/2006/04/11/442448.aspx

You change specific settings with the #if debug then ....

for example my web.config contains the connectionstring to acces the production and testdatabase in my application start there is the following line to acces the diffrent connectionstring

#If DEBUG Then
                constring = ConfigurationManager.ConnectionStrings("aniptestContainer").ConnectionString
#Else
                constring = ConfigurationManager.ConnectionStrings("anipproductionContainer").ConnectionString
#End If

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM