debug/release web.config?

  • Thread starter Thread starter musosdev
  • Start date Start date
M

musosdev

Hi

I've been reading about various ways in which people can have multiple
web.config "sections" for different scenarios (configSource proerty, etc).

In my situation, I just have a dev and production environments, and I'm
using VS2008 .net 3.5.

I'm wondering, is there not some sort of conditional compilation I can do,
where if it's I compile in Debug mode it will use web.config.debug or if I
compile for release it uses web.config.release ?!

Is that at all possible, other than manually renaming the files!?

Thanks,


Dan
 
In general, you can move most of the config elements that will change to
other files. For example, I routinely use db.config for my connection
strings and appSettings.config for app settings. You then exclude publishing
of these files and you can move the rest of the application up to the
server. I find that to be easiest and have yet to have a situation where it
does not work.

Now, if you have elements that cannot be moved to another file, you can play
with the compile (and publish?) to add some post steps that "fix" the
config. At least that is where I would look. I use post build steps
routinely in some of the apps I have under my control.

If neither of these work, you will have to tred carefully. Posting the site
to a staging folder before publishing to the production site is a wise move.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

********************************************
| Think outside the box! |
********************************************
 
The Web Deployment Projects are the solution you're looking for. The section
replacement capabilities can modify any piece of the configuration files
that you need them to. Just install the software, right click on your
website project and click on Add deployment project (think that's the name,
I don't have VS open right now). Should add a new project to your solution,
you can go to the properties for the new project and set the section
replacements in there.

Here's the link:
http://www.microsoft.com/downloads/details.aspx?FamilyId=0AA30AE8-C73B-4BDD-BB1B-FE697256C459

You'll need one deployment project for each environment you plan on
deploying the site to. For example, if you have a development, staging, and
production environment you may consider creating two deployment projects.
One for staging, and another for production, since the development server
can probably use the same settings as the developers who work on the sites.

Also, don't forget to update your build configuration for the solution so
you aren't building the deployment projects unnecessarily when you don't
need them. IE, building the production deployment project when the developer
is trying to use them.

There's quite a bit of resources on the web regarding these projects as
well, so you shouldn't have a problem getting them working for you.

Good luck!
 
Thanks guys, some very helpful info!


Jeff Winn said:
The Web Deployment Projects are the solution you're looking for. The section
replacement capabilities can modify any piece of the configuration files
that you need them to. Just install the software, right click on your
website project and click on Add deployment project (think that's the name,
I don't have VS open right now). Should add a new project to your solution,
you can go to the properties for the new project and set the section
replacements in there.

Here's the link:
http://www.microsoft.com/downloads/details.aspx?FamilyId=0AA30AE8-C73B-4BDD-BB1B-FE697256C459

You'll need one deployment project for each environment you plan on
deploying the site to. For example, if you have a development, staging, and
production environment you may consider creating two deployment projects.
One for staging, and another for production, since the development server
can probably use the same settings as the developers who work on the sites.

Also, don't forget to update your build configuration for the solution so
you aren't building the deployment projects unnecessarily when you don't
need them. IE, building the production deployment project when the developer
is trying to use them.

There's quite a bit of resources on the web regarding these projects as
well, so you shouldn't have a problem getting them working for you.

Good luck!
 
Back
Top