protected internal virtual void SetConfiguration(string config)
{
if (config == null)
{
throw new ArgumentNullException("config");
}
// Can't ask for the active config until the project is opened, so do nothing in that scenario
if (!HasProjectOpened)
return;
// We cannot change properties during the build so if the config
// we want to set is the current, we do nothing otherwise we fail.
if (BuildInProgress)
{
var automationObject = GetAutomationObject() as EnvDTE.Project;
var currentConfigName = Utilities.GetActiveConfigurationName(automationObject);
var configsAreEqual = string.Compare(currentConfigName, config, StringComparison.OrdinalIgnoreCase) == 0;
if (configsAreEqual)
{
return;
}
throw new InvalidOperationException();
}
var propertiesChanged = buildProject.SetGlobalProperty(ProjectFileConstants.Configuration, config);
if (CurrentConfig == null || propertiesChanged)
{
CurrentConfig = buildProject.CreateProjectInstance();
}
if (propertiesChanged || designTimeAssemblyResolution == null)
{
if (designTimeAssemblyResolution == null)
{
designTimeAssemblyResolution = new DesignTimeAssemblyResolution();
}
designTimeAssemblyResolution.Initialize(this);
}
options = null;
}