decates
decates

Reputation: 3535

Replacing entire config file with MSDeploy

I have a ASP.NET web application being deployed using MSDeploy.

Configuring individual attributes/elements via a parameters.xml for the project and corresponding 'SetParameters' files for each environment works fine for a small number of differences.

However, the differences between environments (and the benefit in being able to see whole environment-specific config files) are large-enough that I would rather replace the entire Web.config file.

Can I use SetParams for this, or should I looking at something else?

Needless to say, I'm not keen on storing the entire contents of the config file encoded within a single attribute.

I know I can use config transformations with different build configurations to support this, but that would involve separate builds per environment, which I would rather avoid if possible. I'd rather be able to combine a single build package with a single environment-specific config file in order to deploy to an environment.

Also, this question seems to be similar but there don't appear to be any useful answers to that one.

Any there any other options?

Upvotes: 3

Views: 677

Answers (1)

TheCodeKing
TheCodeKing

Reputation: 19220

The nice thing about parameter files & transforms is that your build artefact does not need to be modifed, and environment config can be injected during deployment time rather than build time.

If you want replace the entire config file then you need a different appproach. You will need to bake all environmental configs file into your package using a naming convention (such as web.dev.config), and then use a postSync powershell command to rename the correct one during post deployment.

I don't recommend it over parameter files, but the approach does work.

Upvotes: 1

Related Questions