This project is read-only.

?BUG? Multiple XLS Settings Files

Jan 6, 2011 at 4:40 PM

I like being able to simply modify values in the XLS and not having to export them to XML., but the use of multiple XLS files does not work the same as multiple XML does.  I say ?BUG? because it may be an unintended feature that the XML files work the way they do (which just happens to be the way I need them to)

I have a "DeveloperEmail" value that upon release is set to send email to all of the developers, but during debug it gets set to the individual developer's email who is debugging so that he gets spammed with errors instead of everyone.

I accomplish this by having a settings-debug.xml that has all of my settings defined in it, and this file is shared by everyone via source control.  Then everyone creates a personal-debug.xml file that defines only the settings that should be specific to them such as this DeveloperEmail value.  Then when calling XmlPreprocess i use "/settings:settings-debug.xml /settings:personal-debug.xml".  XmlPreprocess then uses all of the settings in settings-debug.xml and overwrites those values with any values it finds in personal-debug.xml.  It works great, but it is a pain to modify the excel spreadsheet and then export it to multiple xml files.

 


file: settings-debug.xml

<?xml version="1.0"?>
<!-- This file was generated on 1/5/2011 4:48:06 PM by SettingsFileGenerator.xlsm. Do not edit directly. -->
<settings>
  <property name="DeveloperEmail">developers@mycompany.com</property>
</settings>

file: personal-debug.xml

<?xml version="1.0"?>
<settings>
  <property name="DeveloperEmail">myemail@mycompany.com</property>
</settings>

 


The end result is that ${DeveloperEmail} is myemail@mycompany.com

 

 

The ?Bug? with the XLS files being used directly is that of course the XLS has all of the different build types values in it and they overwrite each other even if undefined.  So ideally I would be able to have one settings.xls file and everyone could have their personal.xls file.  The settings.xls file would be setup as usual with all values in it, then when XmlPreprocess reads additional settings it checks to see if the value it is reading is #undef, and it does not overwrite the previously read value.

Jan 6, 2011 at 8:03 PM

To make the XLS react the way I wanted them to,I went ahead and made the following code modifications to PreprocessingProperties.cs in the Add function:

public void Add(string key, string value)
{
	if (string.IsNullOrEmpty(key))
		return;

	if (ContainsKey(key))
	{
		if (null != value && !value.Equals(_undefToken, StringComparison.OrdinalIgnoreCase)
			&& !value.Equals(NEW_UNDEF_TOKEN, StringComparison.OrdinalIgnoreCase))
		{
			Remove(key);
		}
	}

	if (null != value && !value.Equals(_undefToken, StringComparison.OrdinalIgnoreCase)
		&& !value.Equals(NEW_UNDEF_TOKEN, StringComparison.OrdinalIgnoreCase))
	{
		_properties.Add(new PreprocessingProperty(key, RemoveQuotes(value)));
	}
}