Microsoft.VisualStudio.Project.ConfigProvider.RenameConfiguration C# (CSharp) Method

RenameConfiguration() protected method

protected RenameConfiguration ( Microsoft.Build.Evaluation project, string oldConfigurationName, string newConfigurationName ) : int
project Microsoft.Build.Evaluation
oldConfigurationName string
newConfigurationName string
return int
        protected virtual int RenameConfiguration(MSBuild.Project project, string oldConfigurationName, string newConfigurationName)
        {
            if (project == null)
                throw new ArgumentNullException("project");

            // First create the condition that represent the configuration we want to rename
            string condition = GetConfigurationCondition(oldConfigurationName).Trim();
            string[] platforms = GetPlatformsFromProject();

            foreach (ProjectPropertyGroupElement config in project.Xml.PropertyGroups.ToArray())
            {
                // Only care about conditional property groups
                if (config.Condition == null || config.Condition.Length == 0)
                    continue;

                if (string.Equals(config.Condition.Trim(), condition, StringComparison.OrdinalIgnoreCase))
                {
                    // Change the name
                    config.Condition = GetConfigurationCondition(newConfigurationName);
                }

                foreach (var platform in platforms)
                {
                    string platformCondition = GetConfigurationPlatformCondition(oldConfigurationName, platform).Trim();
                    if (string.Equals(config.Condition.Trim(), platformCondition, StringComparison.OrdinalIgnoreCase))
                    {
                        // Change the name
                        config.Condition = GetConfigurationPlatformCondition(newConfigurationName, platform);
                    }
                }
            }

            return VSConstants.S_OK;
        }