Environmental Override Deployment

Topics: Enterprise Library Core
Jul 10, 2007 at 4:52 PM
I am still a little confused on the Environmental Overrides plugin of the Enterprise Library. I have several articles but none of them address my issue. I am able to add the environments and update the settings per environment. I can see the Production.config & Production.dconfig files in my project after right clicking the Production environment and selecting "Save Merged Configuration", but that is as far as any of the documentation goes. My question is when I publish this site to the production server how does it know to look at the Production.config rather than the web.config (because the web.config has the wrong connection strings obviously)?????

I'm sure I'm missing something totally obvious...

Thanks for your help!
Jul 10, 2007 at 5:43 PM
Hi,

You're supposed replace your original web config with the Production.config as part of your deployment to the production environment. If you're using the "publish web site" feature from VS you'll need to either rename the file before publishing or do it manually after VS is done.

Hope this helps,
Fernando
Jul 10, 2007 at 7:21 PM
Fernando,

Thanks so much for the reply. Although that will work, it just seems strange. It would be great to have a solution that required no user intervention (like if it could detect the environment based on the host name and use the correct config file). Otherwise I don't really see much use for this feature because it is just as easy to just update the connection string before publishing...

Any thoughts??

Thanks again for your quick reply!
Jul 10, 2007 at 7:30 PM
Hi,

I agree the experience is not as smooth as it could be, and just changing a connection string might not be worth the effort. For more complex configurations, deployed using a more robust or automated procedure, the situation changes.

I think the "Publish web site" feature, if that is what you're using, is not well suited to this scenario where you might have different configurations for different environments, regardless of whether you're using the merge configuration tool or not. Just my $.02...

Regards,
Fernando
Jul 10, 2007 at 8:28 PM
Thanks Fernando,

I totally agree. I can see how it would be somewhat useful if there were a log of settings in config that needed to be changed based on environment, but even in this scenario there should be a way to automate it based on the host that is running. In the past I have just used config fragments for sections that change based on environment and when the app starts I modify & save the config fragments as needeed. Just takes a little coding up front but after that it is maintenance free. I would like to see enterprise library go in this direction (as i'm sure everyone else would too). :-)

Thanks again for your help!

I was also wondering why the overrides settings dissappear after closing the config editor. I realize that I have to open the environment files to get them to show up in the config editor after closing and re-opening the config file in the editor but for some reason it is not saving the overrides settings. This would be a huge pain if I were constantly needing to change the overrides settings because I would have to completely re-configure every time. Is that how it is supposed to work??

Thanks!
Jul 10, 2007 at 10:09 PM
Edited Jul 10, 2007 at 10:10 PM
Hi,

This is actually by design. The tool will not reload the overries because the main configuration file doesn't have a link to the override files. However, you can reload an override throught the "Open environment delta" option in the context menu on the "Environments" node.

This is actually a FAQ (but there isn't a FAQ compilation yet :(), and I think there is an earlier post on this.

Regards,
Fernando


jfkrueger wrote:
...
I was also wondering why the overrides settings dissappear after closing the config editor. I realize that I have to open the environment files to get them to show up in the config editor after closing and re-opening the config file in the editor but for some reason it is not saving the overrides settings. This would be a huge pain if I were constantly needing to change the overrides settings because I would have to completely re-configure every time. Is that how it is supposed to work??

Thanks!

Jul 11, 2007 at 5:14 PM
Thanks Fernando,

I know I can re-open the environmental delta but when I do the overrides settings on my connection strings are gone and I have to set them up again. I know it is by design that they do not automatically show up in the config editor and that you have to re-open them but I don't get why my overrides settings would be gone once I do re-open the environmental delta. If this is the case then every time I re-open the delta I have to go set all of my overrides settings again. That can't be right and if it is it seems like a pretty big flaw.

It seems like they stopped short of finishing this piece. Hopefully there will be a link to the proper config files someday so that the developer doesn't have to do the prep work to publish a solution. It is kind of a pain if there are several projects in the solution with different environments to manually go setup the proper config files in each project.


Thanks again!
Jul 11, 2007 at 5:27 PM
Hi,


jfkrueger wrote:
Thanks Fernando,

I know I can re-open the environmental delta but when I do the overrides settings on my connection strings are gone and I have to set them up again. I know it is by design that they do not automatically show up in the config editor and that you have to re-open them but I don't get why my overrides settings would be gone once I do re-open the environmental delta. If this is the case then every time I re-open the delta I have to go set all of my overrides settings again. That can't be right and if it is it seems like a pretty big flaw.



What you're describing looks like an error. I just tried it with the 3.1 signed binaries on the stand alone tool and it worked. By worked I mean:
  • Create a new configuration file
  • Add an environment
  • Add the data block
  • Set "override properties" for the "Overrides on Environment" for the default "Connection String"
  • Expand the overrides property and change the connection string on the override
  • Save and close
  • Open again the file
  • Load the overrides for the environment
  • Go to the connection string node, expand the overrides property and verify the value for the connection string is the updated one (the value on the "main" property should still be the same though)

Regards,
Fernando
Jul 11, 2007 at 8:27 PM
Well, that's good news. I'm sure I just did something wrong. I'll try the whole thing over again.

Thanks again for all of your help!

Joe