/// <summary> /// Helper used to create the empty project file. /// Note that we need to set the IsExplicitlyLoaded property on the ProjectRootElement to true to make sure /// it is not cleared from the ProjectRootElementCache. Unfortuantely, the constructure which creates a new /// empty project does not set this flag. However, the one which can be created from an XmlReader does. So we use /// that one to create the project file in memory and then set the path to make sure it is added correctly to the cache. /// </summary> private ProjectRootElement CreateEmptyMsBuildProject(string projectFilePath, ProjectCollection collection) { using (XmlReader reader = EmptyProject.CreateReader()) { ProjectRootElement importFile = ProjectRootElement.Create(reader, collection); importFile.FullPath = projectFilePath; return(importFile); } }
/// <summary> /// Helper used to create the empty project file. /// Note that we need to set the IsExplicitlyLoaded property on the ProjectRootElement to true to make sure /// it is not cleared from the ProjectRootElementCache. Unfortuantely, the constructure which creates a new /// empty project does not set this flag. However, the one which can be created from an XmlReader does. So we use /// that one to create the project file in memory and then set the path to make sure it is added correctly to the cache. /// </summary> private ProjectRootElement CreateEmptyMsBuildProject(string projectFilePath, ProjectCollection collection) { using (XmlReader reader = EmptyProject.CreateReader()) { #if VS14 ProjectRootElement importFile = ProjectRootElement.Create(reader, collection); #else ProjectRootElement importFile = ProjectRootElement.Create(reader, collection, preserveFormatting: false); #endif importFile.FullPath = projectFilePath; return(importFile); } }