Exemple #1
0
        public void GenerateSolution(string solutionPath)
        {
            if (this.m_SolutionTransform == null)
            {
                var resolver = new EmbeddedResourceResolver();
                this.m_SolutionTransform = new XslCompiledTransform();
                this.m_SolutionTransform.Load(
                    "GenerateSolution.xslt",
                    XsltSettings.TrustedXslt,
                    resolver
                    );
            }

            var input = this.CreateInputFor(this.m_Platform);

            using (var writer = new StreamWriter(solutionPath))
            {
                this.m_SolutionTransform.Transform(input, null, writer);
            }
        }
Exemple #2
0
        public void Generate(string project)
        {
            if (this.m_ProjectTransform == null)
            {
                var resolver = new EmbeddedResourceResolver();
                this.m_ProjectTransform = new XslCompiledTransform();
                this.m_ProjectTransform.Load(
                    "GenerateProject.xslt",
                    XsltSettings.TrustedXslt,
                    resolver
                    );
            }

            // Work out what document this is.
            var projectDoc = this.m_ProjectDocuments.First(
                x => x.DocumentElement.Attributes["Name"].Value == project);

            // Check to see if we have a Project node; if not
            // then this is an external or other type of project
            // that we don't process.
            if (projectDoc == null ||
                projectDoc.DocumentElement.Name != "Project")
            {
                return;
            }

            // Work out what path to save at.
            var path = Path.Combine(
                this.m_RootPath,
                projectDoc.DocumentElement.Attributes["Path"].Value,
                projectDoc.DocumentElement.Attributes["Name"].Value + "." +
                this.m_Platform + ".csproj");

            path = new FileInfo(path).FullName;

            // Work out what path the NuGet packages.config might be at.
            var packagesPath = Path.Combine(
                this.m_RootPath,
                projectDoc.DocumentElement.Attributes["Path"].Value,
                "packages.config");

            // Generate the input document.
            var input = this.CreateInputFor(
                project,
                this.m_Platform,
                packagesPath);

            // Transform the input document using the XSLT transform.
            var settings = new XmlWriterSettings();

            settings.Indent = true;
            using (var writer = XmlWriter.Create(path, settings))
            {
                this.m_ProjectTransform.Transform(input, writer);
            }

            // Also remove any left over .sln or .userprefs files.
            var slnPath = Path.Combine(
                this.m_RootPath,
                projectDoc.DocumentElement.Attributes["Path"].Value,
                projectDoc.DocumentElement.Attributes["Name"].Value + "." +
                this.m_Platform + ".sln");
            var userprefsPath = Path.Combine(
                this.m_RootPath,
                projectDoc.DocumentElement.Attributes["Path"].Value,
                projectDoc.DocumentElement.Attributes["Name"].Value + "." +
                this.m_Platform + ".userprefs");

            if (File.Exists(slnPath))
            {
                File.Delete(slnPath);
            }
            if (File.Exists(userprefsPath))
            {
                File.Delete(userprefsPath);
            }
        }