public override bool Execute() { if (string.Compare(this.Platform, "Web", StringComparison.InvariantCultureIgnoreCase) == 0) { // Trigger JSIL provider download if needed. string jsilDirectory, jsilCompilerFile; var jsilProvider = new JSILProvider(); if (!jsilProvider.GetJSIL(out jsilDirectory, out jsilCompilerFile)) { return false; } } this.LogMessage( "Starting generation of projects for " + this.Platform); var module = ModuleInfo.Load(Path.Combine(this.RootPath, "Build", "Module.xml")); var definitions = module.GetDefinitionsRecursively().ToArray(); // Run Protobuild in batch mode in each of the submodules // where it is present. foreach (var submodule in module.GetSubmodules()) { this.LogMessage( "Invoking submodule generation for " + submodule.Name); submodule.RunProtobuild("-generate " + Platform); this.LogMessage( "Finished submodule generation for " + submodule.Name); } var generator = new ProjectGenerator( this.RootPath, this.Platform, this.LogMessage); foreach (var definition in definitions) { this.LogMessage("Loading: " + definition.Name); generator.Load(Path.Combine( definition.ModulePath, "Build", "Projects", definition.Name + ".definition"), module.Path, definition.ModulePath); } List<string> repositoryPaths = new List<string> (); foreach (var definition in definitions.Where(x => x.ModulePath == module.Path)) { string repositoryPath; generator.Generate( definition.Name, out repositoryPath, () => this.LogMessage("Generating: " + definition.Name)); // Only add repository paths if they should be generated. if (module.GenerateNuGetRepositories && !string.IsNullOrEmpty (repositoryPath)) repositoryPaths.Add (repositoryPath); } var solution = Path.Combine( this.RootPath, this.ModuleName + "." + this.Platform + ".sln"); this.LogMessage("Generating: (solution)"); generator.GenerateSolution(solution, repositoryPaths); this.LogMessage( "Generation complete."); return true; }
private XmlDocument CreateInputFor( string project, string platform, string packagesPath, IEnumerable<XmlElement> properties) { var doc = new XmlDocument(); doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", null)); var input = doc.CreateElement("Input"); doc.AppendChild(input); var generation = doc.CreateElement("Generation"); var projectName = doc.CreateElement("ProjectName"); projectName.AppendChild(doc.CreateTextNode(project)); var platformName = doc.CreateElement("Platform"); platformName.AppendChild(doc.CreateTextNode(platform)); var hostPlatformName = doc.CreateElement("HostPlatform"); hostPlatformName.AppendChild(doc.CreateTextNode(Actions.DetectPlatform())); if (string.Compare(platform, "Web", StringComparison.InvariantCultureIgnoreCase) == 0) { // Add JSIL properties string jsilDirectory, jsilCompilerFile; var jsilProvider = new JSILProvider(); if (!jsilProvider.GetJSIL(out jsilDirectory, out jsilCompilerFile)) { throw new InvalidOperationException("JSIL not found, but previous check passed."); } var jsilDirectoryNode = doc.CreateElement("JSILDirectory"); jsilDirectoryNode.AppendChild(doc.CreateTextNode(jsilDirectory)); generation.AppendChild(jsilDirectoryNode); var jsilCompilerPathNode = doc.CreateElement("JSILCompilerFile"); jsilCompilerPathNode.AppendChild(doc.CreateTextNode(jsilCompilerFile)); generation.AppendChild(jsilCompilerPathNode); var jsilLibrariesNode = doc.CreateElement("JSILLibraries"); foreach (var entry in jsilProvider.GetJSILLibraries()) { var entryNode = doc.CreateElement("Library"); var pathAttribute = doc.CreateAttribute("Path"); pathAttribute.Value = entry.Key; var nameAttribute = doc.CreateAttribute("Name"); nameAttribute.Value = entry.Value; entryNode.Attributes.Append(pathAttribute); entryNode.Attributes.Append(nameAttribute); jsilLibrariesNode.AppendChild(entryNode); } generation.AppendChild(jsilLibrariesNode); // Automatically extract the JSIL template if not already present. var currentProject = this.m_ProjectDocuments.Select(x => x.DocumentElement) .Where(x => x.Attributes != null) .Where(x => x.Attributes["Name"] != null) .FirstOrDefault(x => x.Attributes["Name"].Value == project); if (currentProject != null) { string type = null; string path = null; if (currentProject.Attributes != null && currentProject.Attributes["Type"] != null) { type = currentProject.Attributes["Type"].Value; } if (currentProject.Attributes != null && currentProject.Attributes["Path"] != null) { path = currentProject.Attributes["Path"].Value; } if (string.Compare(type, "App", StringComparison.InvariantCultureIgnoreCase) == 0 || string.Compare(type, "Console", StringComparison.InvariantCultureIgnoreCase) == 0 || string.Compare(type, "GUI", StringComparison.InvariantCultureIgnoreCase) == 0 || string.Compare(type, "GTK", StringComparison.InvariantCultureIgnoreCase) == 0) { if (path != null) { var srcDir = Path.Combine(this.m_RootPath, path); if (Directory.Exists(srcDir)) { if (!File.Exists(Path.Combine(srcDir, "index.htm"))) { Console.WriteLine("Extracting JSIL HTML template..."); ResourceExtractor.ExtractJSILTemplate(project, Path.Combine(srcDir, "index.htm")); } } } } } } var rootName = doc.CreateElement("RootPath"); rootName.AppendChild(doc.CreateTextNode( new DirectoryInfo(this.m_RootPath).FullName)); var useCSCJVM = doc.CreateElement("UseCSCJVM"); useCSCJVM.AppendChild(doc.CreateTextNode( this.IsUsingCSCJVM(platform) ? "True" : "False")); generation.AppendChild(projectName); generation.AppendChild(platformName); generation.AppendChild(hostPlatformName); generation.AppendChild(rootName); generation.AppendChild(useCSCJVM); input.AppendChild(generation); var propertiesNode = doc.CreateElement("Properties"); foreach (var property in properties) { if (property.Name.ToLower() == "property") { var nodeName = doc.CreateElement(property.GetAttribute("Name")); nodeName.AppendChild(doc.CreateTextNode( property.GetAttribute("Value"))); propertiesNode.AppendChild(nodeName); } else propertiesNode.AppendChild( doc.ImportNode(property, true)); } input.AppendChild(propertiesNode); var nuget = doc.CreateElement("NuGet"); input.AppendChild(nuget); var projects = doc.CreateElement("Projects"); input.AppendChild(projects); foreach (var projectDoc in this.m_ProjectDocuments) { projects.AppendChild(doc.ImportNode( projectDoc.DocumentElement, true)); } // Also check if there are NuGet packages.config file for // this project and if there is, include all of the relevant // NuGet package information for referencing the correct DLLs. if (File.Exists(packagesPath)) { this.DetectNuGetPackages( packagesPath, doc, nuget); } return doc; }