bool TryParseProjectConfigurationKey(string key, out Guid guid, out ConfigurationAndPlatform config)
        {
            guid   = default(Guid);
            config = default(ConfigurationAndPlatform);

            int firstDot  = key.IndexOf('.');
            int secondDot = key.IndexOf('.', firstDot + 1);

            if (firstDot < 0 || secondDot < 0)
            {
                return(false);
            }

            string guidText = key.Substring(0, firstDot);

            if (!Guid.TryParse(guidText, out guid))
            {
                return(false);
            }

            string configKey = key.Substring(firstDot + 1, secondDot - (firstDot + 1));

            config = ConfigurationAndPlatform.FromKey(configKey);
            return(config != default(ConfigurationAndPlatform));
        }
 void LoadProjectConfigurations(SolutionSection section, Dictionary <Guid, ProjectLoadInformation> projectInfoDict)
 {
     foreach (var pair in section)
     {
         // pair is an entry like this: '{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU'
         if (pair.Key.EndsWith(".ActiveCfg", StringComparison.OrdinalIgnoreCase))
         {
             Guid guid;
             ConfigurationAndPlatform solutionConfig;
             if (!TryParseProjectConfigurationKey(pair.Key, out guid, out solutionConfig))
             {
                 continue;
             }
             ProjectLoadInformation projectInfo;
             if (!projectInfoDict.TryGetValue(guid, out projectInfo))
             {
                 continue;
             }
             var projectConfig = ConfigurationAndPlatform.FromKey(pair.Value);
             if (projectConfig == default(ConfigurationAndPlatform))
             {
                 continue;
             }
             projectInfo.ConfigurationMapping.SetProjectConfiguration(solutionConfig, projectConfig);
             // Disable build if we see a '.ActiveCfg' entry.
             projectInfo.ConfigurationMapping.SetBuildEnabled(solutionConfig, false);
         }
     }
     // Enable build/deploy if we see the corresponding entries:
     foreach (var pair in section)
     {
         // pair is an entry like this: '{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.Build.0 = Debug|Any CPU'
         Guid guid;
         ConfigurationAndPlatform solutionConfig;
         if (!TryParseProjectConfigurationKey(pair.Key, out guid, out solutionConfig))
         {
             continue;
         }
         ProjectLoadInformation projectInfo;
         if (!projectInfoDict.TryGetValue(guid, out projectInfo))
         {
             continue;
         }
         if (pair.Key.EndsWith(".Build.0", StringComparison.OrdinalIgnoreCase))
         {
             projectInfo.ConfigurationMapping.SetBuildEnabled(solutionConfig, true);
         }
         else if (pair.Key.EndsWith(".Deploy.0", StringComparison.OrdinalIgnoreCase))
         {
             projectInfo.ConfigurationMapping.SetDeployEnabled(solutionConfig, true);
         }
     }
 }
Example #3
0
 internal void LoadPreferences()
 {
     try {
         preferences = SD.PropertyService.LoadExtraProperties(GetPreferencesKey());
     } catch (IOException) {
     } catch (XmlException) {
         // ignore errors about inaccessible or malformed files
     }
     // Load active configuration from preferences
     CreateDefaultConfigurationsIfMissing();
     this.ActiveConfiguration = ConfigurationAndPlatform.FromKey(preferences.Get("ActiveConfiguration", "Debug|Any CPU"));
     ValidateConfiguration();
     // We can't set the startup project property yet; LoadPreferences() is called before
     // the projects are loaded into the solution.
     // This is necessary so that the projects can be loaded in the correct configuration
     // - we avoid an expensive configuration switch during solution load.
 }
 internal IEnumerable <ConfigurationAndPlatform> LoadSolutionConfigurations(IEnumerable <KeyValuePair <string, string> > section)
 {
     // Entries in the section look like this: 'Debug|Any CPU = Debug|Any CPU'
     return(section.Select(e => ConfigurationAndPlatform.FromKey(e.Key))
            .Where(e => ConfigurationAndPlatform.IsValidName(e.Configuration) && ConfigurationAndPlatform.IsValidName(e.Platform)));
 }