2

I've been making some headway using Web Deploy packages that transform web.config files on deploy rather than build. The goal in this is "build once, deploy everywhere". The problem I'm having is when I need to add or change complex XML in a web.config.

For example, if my base web.config contains this:

<customSection>
</customSection>

I might want to the deployed web.config to look like this:

<customSection>
    <someSettingKey>QA Setting</someSettingKey>
</customSection>

It seems to work to have my SetParameters.xml look something like:

<setParameter name="customSection" value="&lt;someSettingKey&gt;QA Setting&lt;/someSettingKey&gt;" />

But that seems a bit cumbersome, especially when the XML gets more nested / complex.

Are there better ways of doing this?

2
  • I really find this approach ridiculous. What makes it worse is that it's the "official" solution from Microsoft. I have some fairly complex XML sections that need to be added at deployment time from TFS into Azure, and this is just horrible to work with. Commented May 4, 2017 at 11:33
  • @MarkRichman Agreed. We eventually stopped using Web Deploy and started using Octopus Deploy for on-premise stuff. Commented May 4, 2017 at 21:25

1 Answer 1

1

I was able to break up the configuration a bit so that the base web.config (for local testing) has the simple XML, and have one transform for the Release configuration (i.e. what runs on the servers). This transform adds the complex XML, and only a few keys within it need to change via the SetParameters.xml for QA, Production, etc.

The complexity in the XML came from encrypting a web.config section. The encryption (and thus, complexity) is only needed on the server.

I suppose another way to do it might be breaking up the config files using the configSource attribute for certain sections... however I didn't really flesh that out.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.