0

As part of our installation of new versions we have web.config.delta files that adjust the existing web.config files as appropriate. Now I know how to add/update/remove AppSetting keys (as all the posts I've found on this have been about that) but what I don't know how to do is add new section elements, add new sectiongroup.

ie. this is all the new stuff in my web.config. What do I need to change to make it get applied as a "delta"?

<?xml version="1.0"?>
<configuration xmlns:xmu="urn:msbuildcommunitytasks-xmlmassupdate">

<configSections>
<section xmu:key="name" name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
<section xmu:key="name" name="securityConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Security.Configuration.SecuritySettings, Microsoft.Practices.EnterpriseLibrary.Security, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />

<sectionGroup name="authorization" type="Company.Security.Configuration.AuthorizationSectionGroup, Company.Library">
      <section name="rowLevelSecurity" type="Company.Security.Configuration.RowLevelAuthorizationSection, Company.Library"/>
      <section name="typeBasedSecurity" type="Company.Security.Configuration.TypeAuthorizationSection, Company.Library"/>
    </sectionGroup>

</configSections>

<enterpriseLibrary.ConfigurationSource selectedSource="System Configuration Source">
    <sources>
      <add name="System Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      <add name="Security-FileBasedConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        filePath="Config/Enterprise-Security.config" />
    </sources>
    <redirectSections>
      <add sourceName="Security-FileBasedConfigurationSource" name="securityConfiguration" />
    </redirectSections>
  </enterpriseLibrary.ConfigurationSource>

  <authorization>
    <rowLevelSecurity defaultProvider="SqlMembershipRowLevelSecurity">
      <providers>
        <add name="SqlMembershipRowLevelSecurity" type="Company.Security.DataAuthorization.SqlMembershipRowLevelSecurityProvider, Company.Library"  applicationName="app1" connectionStringName="SecurityConnection"/>
      </providers>
    </rowLevelSecurity>
    <typeBasedSecurity defaultProvider="SqlInPlaceTypeBasedSecurity">
      <providers>
        <add name="SqlInPlaceTypeBasedSecurity" type="Company.Security.Providers.SqlEntityTypeFunctionTypeSecurityProvider, Company.Common"  applicationName="app1" connectionStringName="SecurityConnection"/>
      </providers>
    </typeBasedSecurity>
  </authorization>

</configuration>

I can't seem to find any simple information on this stuff - but maybe I'm googling with the wrong terminology.

Do I just need to replace the add bits like:

<add name="System Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

<add xmu:key="name" name="System Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" xmu:action="add" />

or do I have to do the same things for the section, sectiongroup and enterpriseLibrary.ConfigurationSource elements??

Thanks!

Jen
  • 1,964
  • 9
  • 33
  • 59
  • 1
    Did you consider solving this using MSDeploy? There's a [great demo from Scott Hanselman at MIX10](http://channel9.msdn.com/events/MIX/MIX10/FT14). – Filburt Jul 11 '11 at 10:32
  • Thanks for the suggestion will go and check it out. We have an established build process that uses this Mass XML Update. Thankfully I found a unit test that does the merge so could use trial and error to figure out what I needed to do. Will check out the other demo though :) – Jen Jul 12 '11 at 05:06
  • Video is interesting - but we're not using VS2010 just yet - and it look kinds of similar to what we're doing. Instead of using XML-Document-Transform we use the syntax that the XML Mass Update uses. It's just the case of remembering which bits you need to put and where :) Plus our differences are unique to each client - not to configuration manager modes (eg. debug/release). – Jen Jul 12 '11 at 05:32
  • You can have as many configurations as you like - Scott briefly mentions adding staging and acceptance testing configurations - but since changing your build process is out of the question and you found a working solution ... – Filburt Jul 12 '11 at 08:51
  • From what I interpreted that part was - you could set it so that if you selected to Build for that environment it would apply the appropriate config changes - which is cool. However we do one build and it's only when it comes time for installation do we use our web.config.deltas to apply changes to client's existing web.config files. Which is why I didn't think it was applicable to my situation (don't get me wrong - I appreciate the link, just that I didn't think it would work with what we do :( ). Plus I didn't really explain the whole process enough :) – Jen Jul 14 '11 at 07:52
  • The main reason I find xml mass update a pain - is the lack of examples I found in order to remember exactly what had to go into the delta file :( – Jen Jul 14 '11 at 07:55

1 Answers1

0

So thankfully I found a unit test that was doing a merge so in memory I could check the XML after the merge. So using trial and error found I needed the below:

<?xml version="1.0"?>
<configuration xmlns:xmu="urn:msbuildcommunitytasks-xmlmassupdate" xmlns:un="http://schemas.microsoft.com/practices/2010/unity">

  <configSections>
    <section xmu:key="name" name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" xmu:action="add" />
    <section xmu:key="name" name="securityConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Security.Configuration.SecuritySettings, Microsoft.Practices.EnterpriseLibrary.Security, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" xmu:action="add"/>

    <sectionGroup xmu:key="name" name="authorization" type="Company.Security.Configuration.AuthorizationSectionGroup, Company.Library" xmu:action="add">
      <section xmu:key="name" name="rowLevelSecurity" type="Company.Security.Configuration.RowLevelAuthorizationSection, Company.Library" xmu:action="add"/>
      <section xmu:key="name" name="typeBasedSecurity" type="Company.Security.Configuration.TypeAuthorizationSection, Company.Library" xmu:action="add"/>
    </sectionGroup>

  </configSections>

  <enterpriseLibrary.ConfigurationSource selectedSource="System Configuration Source">
    <sources>
      <add xmu:key="name" name="System Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" xmu:action="add" />
      <add xmu:key="name" name="Security-FileBasedConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        filePath="Config/Enterprise-Security.config" xmu:action="add" />
    </sources>
    <redirectSections>
      <add xmu:key="name" sourceName="Security-FileBasedConfigurationSource" name="securityConfiguration" xmu:action="add" />
    </redirectSections>
  </enterpriseLibrary.ConfigurationSource>

  <authorization>
    <rowLevelSecurity defaultProvider="SqlMembershipRowLevelSecurity">
      <providers>
        <add xmu:key="name" name="SqlMembershipRowLevelSecurity" type="Company.Security.DataAuthorization.SqlMembershipRowLevelSecurityProvider, Company.Library"  applicationName="app1" connectionStringName="SecurityConnection" xmu:action="add" />
      </providers>
    </rowLevelSecurity>
    <typeBasedSecurity defaultProvider="SqlInPlaceTypeBasedSecurity">
      <providers>
        <add xmu:key="name" name="SqlInPlaceTypeBasedSecurity" type="InPlace.Security.Providers.SqlEntityTypeFunctionTypeSecurityProvider, InPlace.Common"  applicationName="app1" connectionStringName="SecurityConnection" xmu:action="add"/>
      </providers>
    </typeBasedSecurity>
  </authorization>

  <un:unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
    <un:container>
      <un:register xmu:key="type" type="Company.Interface.Logging.ILoggingProvider, Company.Library" mapTo="Company.NHibernate.LoggingProvider, Company.NHibernate" xmu:action="add">
        <un:lifetime type="singleton" />
      </un:register>
      <un:register xmu:key="type" type="Company.Interface.Security.ITaskAuthorizationManager, Company.Library" mapTo="Company.EnterpriseLibrary.Security.TaskAuthorizationManager, Company.EnterpriseLibrary" xmu:action="add" >
        <un:lifetime type="singleton" />
      </un:register>
      <un:register xmu:key="type" type="Company.Interface.Security.ITypeAuthorizationManager, Company.Library" mapTo="Company.EnterpriseLibrary.Security.TypeAuthorizationManager, Company.EnterpriseLibrary" xmu:action="add" >
        <un:lifetime type="singleton" />
      </un:register>
      <un:register xmu:key="type" type="Company.Interface.Security.IPropertyAuthorizationManager, Company.Library" mapTo="Company.EnterpriseLibrary.Security.PropertyAuthorizationManager, Company.EnterpriseLibrary" xmu:action="add" >
        <un:lifetime type="singleton" />
      </un:register>
      <un:register xmu:key="type" type="Company.Interface.Security.IRoleAuthorizationManager, Company.Library" mapTo="Company.Web.Security.RoleAuthorizationManager, Company.Library" xmu:action="add">
        <un:lifetime type="singleton" />
      </un:register>
      <un:register xmu:key="type" type="Company.Interface.Security.IRowLevelAuthorizationManager, Company.Library" mapTo="Company.Web.Security.RowLevelAuthorizationManager, Company.Library" xmu:action="add">
        <un:lifetime type="singleton" />
      </un:register>
      <un:register xmu:key="type" name="TypeSecurityProvider" type="Company.Security.TypeBasedAuthorization.TypeSecurityProvider, Company.Library" mapTo="Company.Security.Providers.SqlEntityTypeFunctionTypeSecurityProvider, Company.Common" xmu:action="add"/>
    </un:container>
  </un:unity>

</configuration>
Jen
  • 1,964
  • 9
  • 33
  • 59