private void EnsureCpsProjFile(string cpsProjFileName)
        {
            var fileInfo = new FileInfo(cpsProjFileName);

            if (fileInfo.Exists)
            {
                return;
            }

            var xProj = new XProject();

            xProj.Add(
                new XPropertyGroup("Globals", null,
                                   new XProperty("ProjectGuid", Guid.NewGuid().ToString("D")),
                                   new XProperty("ManifestPath", "Cargo.toml")
                                   ),
                new XProjElement("Import", new XAttribute("Project", @"$(MSBuildExtensionsPath)\VisualRust\VisualRust.Rust.targets")),
                new XProjElement("Import",
                                 new XAttribute("Project", @"$(MSBuildThisFileName).InMemory.Targets"),
                                 new XAttribute("Condition", "Exists('$(MSBuildThisFileName).InMemory.Targets')")
                                 )
                );

            var xProjDocument = new XProjDocument(xProj);

            using (var writer = fileInfo.CreateText())
            {
                xProjDocument.Save(writer);
            }
        }
        private void EnsureCpsProjFile(string cpsProjFileName)
        {
            var fileInfo            = new FileInfo(cpsProjFileName);
            var inMemoryTargetsFile = FileSystemMirroringProjectUtilities.GetInMemoryTargetsFileName(cpsProjFileName);

            var xProjDocument = new XProjDocument(
                new XProject(Toolset.Version, "Build",
                             new XPropertyGroup("Globals", null,
                                                new XProperty("ProjectGuid", Guid.NewGuid().ToString("D"))
                                                ),
                             new XPropertyGroup(
                                 new XDefaultValueProperty("VisualStudioVersion", Toolset.Version),
                                 new XDefaultValueProperty("Configuration", "Debug"),
                                 new XDefaultValueProperty("Platform", "AnyCPU")
                                 ),
                             CreateProjectUiSubcaption(),
                             new XProjElement("ProjectExtensions",
                                              new XProjElement("VisualStudio",
                                                               new XProjElement("UserProperties")
                                                               )
                                              ),
                             _msBuildImports.SelectMany(CreateMsBuildExtensionXImports),
                             new XImportExisting(inMemoryTargetsFile)
                             )
                );

            if (fileInfo.Exists)
            {
                fileInfo.Delete();
            }

            using (var writer = fileInfo.CreateText()) {
                xProjDocument.Save(writer);
            }
        }
Exemple #3
0
 static FileSystemMirroringProject()
 {
     EmptyProject = new XProjDocument(new XProject());
 }