2
votes

Visual Studio 2012 Express, MVC 4 App: Selecting 'Debug' or 'Release' in solution configuration drop down doesn't work.

I have Web.Release.Config & Web.Debug.Config. There is a transform

   <appSettings>
      <add key="Environment" value="Release" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
   </appSettings>

that changes this in web.config:

 <add key="Environment" value="DEVELOPMENT" />

to this in release mode (web.release.config)

 <add key="Environment" value="Release" />

I have previewed it by right clicking on Web.Release.Config and 'preview transform' - and it behaves as it should.

On a view I have the following: @System.Configuration.ConfigurationManager.AppSettings["Environment"]

It always shows 'DEVELOPMENT' - it is never blank - regardless whether I select 'Debug' or 'Release' from the solution configuration drop down prior to clicking 'start without debugging'

Debug or Release menu

Shouldn't this work? Thanks.

1

1 Answers

0
votes

Yeah so, Microsoft thought it would be a good idea to not use your custom web.config files when running in debug mode on your local box. Those only get used when you publish.. I guess that's great when.... well, never....