public virtual int RenameCfgsOfCfgName(string old, string newname)
{
if (old == null)
throw new ArgumentNullException("old");
if (newname == null)
throw new ArgumentNullException("newname");
if (string.IsNullOrEmpty(old))
throw new ArgumentException("old cannot be null or empty");
if (string.IsNullOrEmpty(newname))
throw new ArgumentException("newname cannot be null or empty");
// We need to QE/QS the project file
if (!this.ProjectManager.QueryEditProjectFile(false))
{
throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED);
}
foreach (MSBuild.Project project in GetBuildProjects(true))
{
int hr = RenameConfiguration(project, old, newname);
if (ErrorHandler.Failed(hr))
return hr;
}
string[] platforms = GetPlatformsFromProject();
foreach (var platform in platforms)
{
string oldKey = string.Format("{0}|{1}", old, platform);
string newKey = string.Format("{0}|{1}", newname, platform);
// Update the name in our configuration list
ProjectConfig configuration;
if (configurationsList.TryGetValue(oldKey, out configuration))
{
configurationsList.Remove(oldKey);
configurationsList.Add(newKey, configuration);
// notify the configuration of its new name
configuration.ConfigName = newname;
}
}
NotifyOnCfgNameRenamed(old, newname);
return VSConstants.S_OK;
}