Beispiel #1
0
        public static Solution CreateSolution(string name)
        {
            var solution = new Solution();

            solution.Name    = name;
            solution.Version = SolutionVersion.VS2010;

            var solutionConfigPlatforms = new SolutionSection()
            {
                Name        = "SolutionConfigurationPlatforms",
                Type        = "preSolution",
                SectionType = "Global",
            };

            solutionConfigPlatforms.Add(new KeyValuePair <string, string>("Debug|Any CPU", "Debug|Any CPU"));
            solutionConfigPlatforms.Add(new KeyValuePair <string, string>("Release|Any CPU", "Release|Any CPU"));

            solution.GlobalSections.Add(solutionConfigPlatforms);

            var solutionProperties = new SolutionSection()
            {
                Name        = "SolutionProperties",
                Type        = "preSolution",
                SectionType = "Global",
            };

            solutionProperties.Add(new KeyValuePair <string, string>("HideSolutionNode", "FALSE"));
            solution.GlobalSections.Add(solutionProperties);

            return(solution);
        }
        public static Solution CreateSolution(string name)
        {
            var solution = new Solution();
            solution.Name = name;
            solution.Version = SolutionVersion.VS2010;

            var solutionConfigPlatforms = new SolutionSection()
            {
                Name = "SolutionConfigurationPlatforms",
                Type = "preSolution",
                SectionType = "Global",
            };

            solutionConfigPlatforms.Add(new KeyValuePair<string,string>("Debug|Any CPU", "Debug|Any CPU"));
            solutionConfigPlatforms.Add(new KeyValuePair<string,string>("Release|Any CPU", "Release|Any CPU"));

            solution.GlobalSections.Add(solutionConfigPlatforms);

            var solutionProperties = new SolutionSection()
            {
                Name = "SolutionProperties",
                Type = "preSolution",
                SectionType = "Global",
            };

            solutionProperties.Add(new KeyValuePair<string,string>("HideSolutionNode", "FALSE"));
            solution.GlobalSections.Add(solutionProperties);

            return solution;
        }
Beispiel #3
0
		public void WriteProjectSection(SolutionSection section)
		{
			if (section.Count != 0) {
				writer.WriteLine("\tProjectSection({0}) = {1}", section.SectionName, section.SectionType);
				WriteSectionEntries(section);
				writer.WriteLine("\tEndProjectSection");
			}
		}
Beispiel #4
0
		public void WriteSectionEntries(SolutionSection section)
		{
			foreach (var entry in section) {
				writer.Write("\t\t");
				writer.Write(entry.Key);
				writer.Write(" = ");
				writer.Write(entry.Value);
				writer.WriteLine();
			}
		}
        private void WriteSection(SolutionSection section)
        {
            _writer.WriteLine("\t{0}Section({1}) = {2}", section.SectionType, section.Name, section.Type);

            foreach (var entry in section)
            {
                _writer.WriteLine("\t\t{0} = {1}", entry.Key, entry.Value);
            }

            _writer.WriteLine("\tEnd{0}Section", section.SectionType);
        }
		public void GlobalSection()
		{
			SolutionSection section = new SolutionSection("ProjectConfigurationPlatforms", "postSolution");
			section.Add("{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|Any CPU.ActiveCfg", "Debug|Any CPU");
			section.Add("{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|Any CPU.ActiveCfg", "Release|Any CPU");
			StringWriter w = new StringWriter();
			new SolutionWriter(w).WriteGlobalSection(section);
			Assert.AreEqual("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution" + w.NewLine +
			                "\t\t{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|Any CPU.ActiveCfg = Debug|Any CPU" + w.NewLine +
			                "\t\t{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|Any CPU.ActiveCfg = Release|Any CPU" + w.NewLine +
			                "\tEndGlobalSection" + w.NewLine
			                , w.ToString());
		}
Beispiel #7
0
		public void WriteSolutionItem(ISolutionItem item)
		{
			ISolutionFolder folder = item as ISolutionFolder;
			IProject project = item as IProject;
			if (folder != null) {
				WriteProjectHeader(ProjectTypeGuids.SolutionFolder, folder.Name, folder.Name, folder.IdGuid);
				// File items are represented as nodes in the tree, but they're actually
				// saved as properties on their containing folder.
				SolutionSection section = new SolutionSection("SolutionItems", "preProject");
				foreach (var file in folder.Items.OfType<ISolutionFileItem>()) {
					string location = FileUtility.GetRelativePath(basePath, file.FileName);
					section.Add(location, location);
				}
				WriteProjectSection(section);
				writer.WriteLine("EndProject");
			} else if (project != null) {
				string location = FileUtility.GetRelativePath(basePath, project.FileName);
				WriteProjectHeader(project.TypeGuid, project.Name, location, project.IdGuid);
				foreach (var section in project.ProjectSections) {
					WriteProjectSection(section);
				}
				writer.WriteLine("EndProject");
			}
		}
Beispiel #8
0
        private SolutionSection ReadSection(Match match)
        {
            var section = new SolutionSection();
            section.Name = match.Groups["Name"].Value;
            section.SectionType = match.Groups["SectionType"].Value;
            section.Type = match.Groups["Type"].Value;

            ReadNextLine();
            Match sectionMatch;
            while (IsAtKeyValuePair(out sectionMatch))
            {
                section.Add(ReadKeyValuePair(sectionMatch));
                ReadNextLine();
            }

            if (_currentLine != string.Format("End{0}Section", section.SectionType))
                ThrowSyntaxError(string.Format("Expected \"End{0}Section\" keyword.", section.SectionType));

            return section;
        }
Beispiel #9
0
		/// <summary>
		/// Converts the 'NestedProjects' section into a dictionary from project GUID to parent solution folder.
		/// </summary>
		Dictionary<Guid, SolutionFolder> LoadNesting(SolutionSection section, IReadOnlyDictionary<Guid, SolutionFolder> solutionFolderDict)
		{
			var result = new Dictionary<Guid, SolutionFolder>();
			foreach (var entry in section) {
				Guid idGuid;
				Guid parentGuid;
				if (Guid.TryParse(entry.Key, out idGuid) && Guid.TryParse(entry.Value, out parentGuid)) {
					SolutionFolder parentFolder;
					if (solutionFolderDict.TryGetValue(parentGuid, out parentFolder))
						result[idGuid] = parentFolder;
				}
			}
			return result;
		}
Beispiel #10
0
		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);
				}
			}
		}
Beispiel #11
0
		public SolutionSection ReadSection(bool isGlobal)
		{
			if (currentLine == null)
				return null;
			Match match = sectionHeaderPattern.Match(currentLine);
			if (!match.Success)
				return null;
			NextLine();
			
			SolutionSection section = new SolutionSection(match.Groups["Name"].Value, match.Groups["Type"].Value);
			ReadSectionEntries(section);
			string expectedLine = isGlobal ? "EndGlobalSection" : "EndProjectSection";
			if ((currentLine ?? string.Empty).Trim() != expectedLine)
				throw Error("Expected " + expectedLine);
			NextLine();
			return section;
		}
Beispiel #12
0
		void ReadSectionEntries(SolutionSection section)
		{
			while (currentLine != null) {
				int pos = currentLine.IndexOf('=');
				if (pos < 0)
					break; // end of section
				string key = currentLine.Substring(0, pos).Trim();
				string value = currentLine.Substring(pos + 1).Trim();
				section.Add(key, value);
				NextLine();
			}
		}
        public string GetExtensibilityGlobalsSolutionItem(string name)
        {
            SolutionSection section = GetExtensibilityGlobalsSection();

            return(section[name]);
        }
Beispiel #14
0
		SolutionSection GenerateNestingSection(ISolution solution)
		{
			SolutionSection section = new SolutionSection("NestedProjects", "preSolution");
			foreach (var item in solution.AllItems) {
				if (item is ISolutionFileItem)
					continue; // file items are a special case as they're saved in their own section
				if (item.ParentFolder != solution) {
					section.Add(GuidToString(item.IdGuid), GuidToString(item.ParentFolder.IdGuid));
				}
			}
			return section;
		}
Beispiel #15
0
		SolutionSection GenerateSolutionConfigurationSection(IConfigurable solution)
		{
			SolutionSection section = new SolutionSection("SolutionConfigurationPlatforms", "preSolution");
			foreach (var config in solution.ConfigurationNames) {
				foreach (var platform in solution.PlatformNames) {
					string key = config + "|" + platform;
					section.Add(key, key);
				}
			}
			return section;
		}
 public SolutionSectionItem(SolutionSection section, string name)
     : this(section, name, section[name])
 {
 }
 SolutionSectionItem(SolutionSection section, string name, string value)
 {
     this.section = section;
     this.Name    = name;
     this.value   = value;
 }
 private SolutionSection GetGlobalSection(string name, string type, bool createIfNotExist)
 {
     SolutionSection section;
     if ((section = GlobalSections.FirstOrDefault(x => x.Name == name && x.Type == type)) == null && createIfNotExist)
     {
         section = new SolutionSection()
         {
             Name = name,
             Type = type,
             SectionType = "Global",
         };
         GlobalSections.Add(section);
     }
     return section;
 }
Beispiel #19
0
		SolutionSection GenerateProjectConfigurationSection(ISolution solution)
		{
			SolutionSection section = new SolutionSection("ProjectConfigurationPlatforms", "postSolution");
			foreach (var project in solution.Projects) {
				foreach (var configuration in solution.ConfigurationNames) {
					foreach (var platform in solution.PlatformNames) {
						var solutionConfig = new ConfigurationAndPlatform(configuration, platform);
						var projectConfig = project.ConfigurationMapping.GetProjectConfiguration(solutionConfig);
						string key = GuidToString(project.IdGuid) + "." + solutionConfig;
						string value = projectConfig.Configuration + "|" + MSBuildInternals.FixPlatformNameForSolution(projectConfig.Platform);
						section.Add(key + ".ActiveCfg", value);
						if (project.ConfigurationMapping.IsBuildEnabled(solutionConfig))
							section.Add(key + ".Build.0", value);
						if (project.ConfigurationMapping.IsDeployEnabled(solutionConfig))
							section.Add(key + ".Deploy.0", value);
					}
				}
			}
			return section;
		}
 public SolutionSectionItem(SolutionSection section, string name)
     : this(section, name, section[name])
 {
 }
 SolutionSectionItem(SolutionSection section, string name, string value)
 {
     this.section = section;
     this.Name = name;
     this.value = value;
 }
        public void AddVariableToExtensibilityGlobals(string name, string value)
        {
            SolutionSection section = GetExtensibilityGlobalsSection();

            section.Add(name, value);
        }