/// <summary> /// Saves the current contents of the project to a TextWriter object. /// </summary> /// <param name="textWriter"></param> /// <owner>RGoel</owner> public void Save ( TextWriter textWriter ) { using (ProjectWriter projectWriter = new ProjectWriter(textWriter)) { projectWriter.Initialize(mainProjectEntireContents, XmlDeclarationNode); mainProjectEntireContents.Save(projectWriter); } }
/// <summary> /// Saves the current contents of the project to an XML project file on /// disk using the supplied encoding. /// </summary> /// <param name="projectFileName"></param> /// <param name="encoding"></param> /// <owner>LukaszG</owner> public void Save ( string projectFileName, Encoding encoding ) { #if (!STANDALONEBUILD) using (new CodeMarkerStartEnd(CodeMarkerEvent.perfMSBuildProjectSaveToFileBegin, CodeMarkerEvent.perfMSBuildProjectSaveToFileEnd)) #endif { #if MSBUILDENABLEVSPROFILING try { string beginProjectSave = String.Format(CultureInfo.CurrentCulture, "Save Project {0} Using Old OM - Start", projectFileName); DataCollection.CommentMarkProfile(8810, beginProjectSave); #endif // HIGHCHAR: Project.SaveToFileWithEncoding accepts encoding from caller. using (ProjectWriter projectWriter = new ProjectWriter(projectFileName, encoding)) { projectWriter.Initialize(mainProjectEntireContents, XmlDeclarationNode); mainProjectEntireContents.Save(projectWriter); } // Update the project filename/path if it has changed. string newFullProjectFilePath = Path.GetFullPath(projectFileName); if (0 != String.Compare(newFullProjectFilePath, this.FullFileName, StringComparison.OrdinalIgnoreCase)) { this.FullFileName = newFullProjectFilePath; } // reset the dirty flag dirtyNeedToSaveProjectFile = false; #if MSBUILDENABLEVSPROFILING } finally { string endProjectSave = String.Format(CultureInfo.CurrentCulture, "Save Project {0} Using Old OM - End", projectFileName); DataCollection.CommentMarkProfile(8810, endProjectSave); } #endif } }