Wednesday, January 30, 2019

Question about creating environment agnostic ASP.NET artifacts

Please excuse any ignorance or misuse of terminology in my question, I'm a foreigner to this part of the .NET world.

I've inherited an old ASP.NET web application (.NET 4) that gets deployed to IIS 7. The current build and deploy process is done manually and I'm tasked with automating it. If I only had one environment to deploy to, or the same connection strings in each environment, I'd be finished already. But life is never so simple. It's currently set up with separate Web.[configuration].config files that get transformed/overlaid on the base Web.config at build time, giving us a final Web.config file with environment specific connection strings, app settings, etc.

But I want to stop creating environment-specific artifacts. We want to create a build artifact once and then deploy that artifact to development, QA and production without rebuilding. I'm having a hard time coming up with the right solution. My instinct was that I could use an environment-agnostic Web.config file that imported another config file that would be pre-deployed to the environment. For example, it would have a section like: <connectionStrings configSource="C:\configs\connString.config"/>. But that doesn't work because it can't load a config file that isn't in the application directory, so that's a dead end.

I can think of lots of ways to accomplish my goal (like just copying out a new Web.config over top of whatever is there after I've deployed the application) but they all seem a bit hacky. Is there a recommended way of having different configuration values for different environments without creating a new build per environment? This seems like such a standard thing to do and yet I can't find a straight answer, which makes me think I'm missing something obvious.

Thanks in advance!

Question about creating environment agnostic ASP.NET artifacts Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team