MSDeploy Parameters.xml can only replace web.config values is a value is already set

If you are using a parameters.xml file to set value with MSDeploy I have just found a gotcha. You need some value in the web.config file, not just an empty XML tag, else the replacement fails. So to explain…

I had the following parameters.xml file, and use Release Management to replace the __TAG__ values at deployment time.

1<parameters>  
2  <parameter name="Domain" description="Please enter the name of the domain" defaultvalue="\_\_Domain\_\_" tags="">  
3    <parameterentry kind="XmlFile" scope="\\web.config$" match="/configuration/applicationSettings/Web.Properties.Settings/setting\[@name='Domain'\]/value/text()" />  
4  </parameter>
5
6  <parameter name="AdminGroups" description="Please enter the name of the admin group" defaultvalue="\_\_AdminGroups\_\_" tags="">  
7    <parameterentry kind="XmlFile" scope="\\web.config$" match="/configuration/applicationSettings/Web.Properties.Settings/setting\[@name='AdminGroups'\]/value/text()" />  
8  </parameter>  
9</parameters>

If my web.config file (in the MSDeploy package to be transformed) was set to

 1<applicationSettings>  
 2    <Web.Properties.Settings>  
 3      <setting name="Domain" serializeAs="String">  
 4        <value>Blackmarble</value>  
 5      </setting>  
 6      <setting name="AdminGroups" serializeAs="String">  
 7        <value />  
 8      </setting>  
 9    </BlackMarble.ISS.Expenses.Web.Properties.Settings>  
10  </applicationSettings>

or

 1<applicationSettings>  
 2    <Web.Properties.Settings>  
 3      <setting name="Domain" serializeAs="String">  
 4        <value>Blackmarble</value>  
 5      </setting>  
 6      <setting name="AdminGroups" serializeAs="String">  
 7        <value></value>  
 8      </setting>  
 9    </BlackMarble.ISS.Expenses.Web.Properties.Settings>  
10  </applicationSettings>

only the Domain setting was set.

To get both set I had to have a value for each property, even though they were being reset at deployment.

 1<applicationSettings>  
 2    <Web.Properties.Settings>  
 3      <setting name="Domain" serializeAs="String">  
 4        <value>DummyDomain</value>  
 5      </setting>  
 6      <setting name="AdminGroups" serializeAs="String">  
 7        <value>DummyAdmins</value>  
 8      </setting>  
 9    </BlackMarble.ISS.Expenses.Web.Properties.Settings>  
10  </applicationSettings>

Never seen that one before.