How can I change an appSetting value to an empty string on deployment?

I have an appSetting called “foo” with a value of “bar” in my web.config. In my Dev environment, I’d like the value changed from “bar” to an empty string on deployment. I’ve created an Octopus variable call “foo” with an empty value and set the environment to Dev, but the appSetting still has a value of “bar”.

How can I tell Octopus to change that appSetting to an empty string?

Hi,

Thanks for getting in touch. I just added a unit test for this and replacing with an empty variable should work fine. Could you post the output log from the deployment? (Feel free to mark this discussion as Private if you wish).

Paul

I took a look at the log, and noticed a null value exception in the snippet below. The deployment succeeds. I can send the entire log if you’d like.

2012-06-21 15:51:42 INFO Updating any .config files
2012-06-21 15:51:42 DEBUG Scanning configuration file: C:\MyWebSite\Web.config
2012-06-21 15:51:42 DEBUG Setting //appSettings/add[@key=‘foo’] to ''
2012-06-21 15:51:42 WARN Unable to update configuration file: C:\MyWebSite\Web.config
System.ArgumentNullException: Value cannot be null.
Parameter name: value
at System.Xml.Linq.XAttribute.SetValue(Object value)
at Octopus.Tentacle.Conventions.XmlConfigVariables.ReplaceAttributeValues(XNode document, String xpath, String keyAttributeName, String keyAttributeValue, String valueAttributeName, String value) in c:\BuildAgent\work\7bf5272a44079f5\source\Octopus.Tentacle\Conventions\XmlConfigVariables.cs:line 75
at Octopus.Tentacle.Conventions.XmlConfigVariables.UpdateConfigurationFile(String configurationFilePath, ConventionContext context) in c:\BuildAgent\work\7bf5272a44079f5\source\Octopus.Tentacle\Conventions\XmlConfigVariables.cs:line 49
at Octopus.Tentacle.Conventions.XmlConfigVariables.AfterDeployment(ConventionContext context) in c:\BuildAgent\work\7bf5272a44079f5\source\Octopus.Tentacle\Conventions\XmlConfigVariables.cs:line 31

Hi,

Great, thanks for the details. This bug has been fixed:

Paul

Great, thanks!