GetGlobalPropertyGroup() публичный Метод

public GetGlobalPropertyGroup ( ) : MSBuildPropertySet
Результат MSBuildPropertySet
Пример #1
0
        static string LoadProjectTypeGuids(string fileName)
        {
            MSBuildProject project = new MSBuildProject();

            project.Load(fileName);

            MSBuildPropertySet globalGroup = project.GetGlobalPropertyGroup();

            if (globalGroup == null)
            {
                return(null);
            }

            return(globalGroup.GetPropertyValue("ProjectTypeGuids"));
        }
		protected override MSBuildProject SaveProject (IProgressMonitor monitor)
		{
			MSBuildSerializer ser = CreateSerializer ();
			ser.SerializationContext.BaseFile = EntityItem.FileName;
			ser.SerializationContext.ProgressMonitor = monitor;

			MSBuildProject projitemsProject = new MSBuildProject ();
			MSBuildProject msproject = new MSBuildProject ();

			var newProject = EntityItem.FileName == null || !File.Exists (EntityItem.FileName);
			if (newProject) {
				var grp = msproject.GetGlobalPropertyGroup ();
				if (grp == null)
					grp = msproject.AddNewPropertyGroup (false);
				grp.SetPropertyValue ("ProjectGuid", EntityItem.ItemId, false);
				var import = msproject.AddNewImport (@"$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props");
				import.Condition = @"Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')";
				msproject.AddNewImport (@"$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props");
				msproject.AddNewImport (@"$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props");
				import = msproject.AddNewImport (Path.ChangeExtension (EntityItem.FileName.FileName, ".projitems"));
				import.Label = "Shared";
				msproject.AddNewImport (@"$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets");
			} else {
				msproject.Load (EntityItem.FileName);
			}

			// having no ToolsVersion is equivalent to 2.0, roundtrip that correctly
			if (ToolsVersion != "2.0")
				msproject.ToolsVersion = ToolsVersion;
			else if (string.IsNullOrEmpty (msproject.ToolsVersion))
				msproject.ToolsVersion = null;
			else
				msproject.ToolsVersion = "2.0";

			if (projitemsFile == null)
				projitemsFile = Path.ChangeExtension (EntityItem.FileName, ".projitems");
			if (File.Exists (projitemsFile)) {
				projitemsProject.Load (projitemsFile);
			} else {
				var grp = projitemsProject.AddNewPropertyGroup (true);
				grp.SetPropertyValue ("MSBuildAllProjects", "$(MSBuildAllProjects);$(MSBuildThisFileFullPath)", false);
				grp.SetPropertyValue ("HasSharedItems", "true", false);
				grp.SetPropertyValue ("SharedGUID", EntityItem.ItemId, false);

				grp = projitemsProject.AddNewPropertyGroup (true);
				grp.Label = "Configuration";
				grp.SetPropertyValue ("Import_RootNamespace", ((SharedAssetsProject)EntityItem).DefaultNamespace, false);
			}

			SaveProjectItems (monitor, new MSBuildFileFormatVS12 (), ser, projitemsProject, "$(MSBuildThisFileDirectory)");

			projitemsProject.Save (projitemsFile);

			return msproject;
		}
Пример #3
0
		static string LoadProjectTypeGuids (string fileName)
		{
			MSBuildProject project = new MSBuildProject ();
			project.Load (fileName);
			
			MSBuildPropertySet globalGroup = project.GetGlobalPropertyGroup ();
			if (globalGroup == null)
				return null;

			return globalGroup.GetPropertyValue ("ProjectTypeGuids");
		}