public static void AddImportIfMissing(
     this DotNetProject project,
     string importedProjectFile,
     ProjectImportLocation importLocation)
 {
     var msbuildProject = new MSBuildProject ();
     msbuildProject.Load (project.FileName);
     msbuildProject.AddImportIfMissing (importedProjectFile, importLocation, GetCondition (importedProjectFile));
     msbuildProject.Save (project.FileName);
 }
		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;
		}
		public override void LoadProject (MonoDevelop.Core.IProgressMonitor monitor, MonoDevelop.Projects.SolutionEntityItem item, MSBuildProject project)
		{
			var changed = (UpgradeMonoGameProject (monitor, item, project));
			base.LoadProject (monitor, item, project);
			if (changed) {
				project.Save (project.FileName);
			}
		}
 public static void RemoveImport(this DotNetProject project, string importedProjectFile)
 {
     var msbuildProject = new MSBuildProject ();
     msbuildProject.Load (project.FileName);
     msbuildProject.RemoveImportIfExists (importedProjectFile);
     msbuildProject.Save (project.FileName);
 }