Microsoft.VisualStudio.ProjectSystem.FileSystemMirroring.Project.FileSystemMirroringProject.CreateEmptyMsBuildProject C# (CSharp) Method

CreateEmptyMsBuildProject() private method

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.
private CreateEmptyMsBuildProject ( string projectFilePath, Microsoft.Build.Evaluation.ProjectCollection collection ) : Microsoft.Build.Construction.ProjectRootElement
projectFilePath string
collection Microsoft.Build.Evaluation.ProjectCollection
return Microsoft.Build.Construction.ProjectRootElement
        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;
            }
        }