private static string BuildReference(SolutionNode solution, ProjectNode currentProject, ReferenceNode refr) { if (!String.IsNullOrEmpty(refr.Path)) { return refr.Path; } if (solution.ProjectsTable.ContainsKey(refr.Name)) { ProjectNode projectRef = (ProjectNode) solution.ProjectsTable[refr.Name]; string finalPath = Helper.NormalizePath(refr.Name + GetProjectExtension(projectRef), '/'); return finalPath; } ProjectNode project = (ProjectNode) refr.Parent; // Do we have an explicit file reference? string fileRef = FindFileReference(refr.Name, project); if (fileRef != null) { return fileRef; } // Is there an explicit path in the project ref? if (refr.Path != null) { return Helper.NormalizePath(refr.Path + "/" + refr.Name + GetProjectExtension(project), '/'); } // No, it's an extensionless GAC ref, but nant needs the .dll extension anyway return refr.Name + ".dll"; }
private static string BuildReference(SolutionNode solution, ReferenceNode refr) { string ret = "<ProjectReference type=\""; if(solution.ProjectsTable.ContainsKey(refr.Name)) { ret += "Project\""; ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\" refto=\"" + refr.Name + "\" />"; } else { ProjectNode project = (ProjectNode)refr.Parent; string fileRef = FindFileReference(refr.Name, project); if(refr.Path != null || fileRef != null) { ret += "Assembly\" refto=\""; string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef; ret += finalPath; ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; return ret; } ret += "Gac\""; ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\""; ret += " refto=\""; try { /* Day changed to 28 Mar 2007 ... 08:09 < cj> is there anything that replaces Assembly.LoadFromPartialName() ? 08:09 < jonp> no 08:10 < jonp> in their infinite wisdom [sic], microsoft decided that the ability to load any assembly version by-name was an inherently bad idea 08:11 < cj> I'm thinking of a bunch of four-letter words right now... 08:11 < cj> security through making it difficult for the developer!!! 08:12 < jonp> just use the Obsolete API 08:12 < jonp> it should still work 08:12 < cj> alrighty. 08:12 < jonp> you just get warnings when using it */ Assembly assem = Assembly.LoadWithPartialName(refr.Name); ret += assem.FullName; //ret += refr.Name; } catch (System.NullReferenceException e) { e.ToString(); ret += refr.Name; } ret += "\" />"; } return ret; }
private static string BuildReference(SolutionNode solution, ReferenceNode refr) { string ret = ""; if (solution.ProjectsTable.ContainsKey(refr.Name)) { ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; string fileRef = FindFileReference(refr.Name, project); string finalPath = Helper.NormalizePath(Helper.MakeFilePath(project.FullPath + "/${build.dir}/", refr.Name, "dll"), '/'); ret += finalPath; return ret; } else { ProjectNode project = (ProjectNode)refr.Parent; string fileRef = FindFileReference(refr.Name, project); if (refr.Path != null || fileRef != null) { string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path + "/" + refr.Name + ".dll", '/') : fileRef; ret += finalPath; return ret; } try { //Assembly assem = Assembly.Load(refr.Name); //if (assem != null) //{ //ret += (refr.Name + ".dll"); //} //else //{ ret += (refr.Name + ".dll"); //} } catch (System.NullReferenceException e) { e.ToString(); ret += refr.Name + ".dll"; } } return ret; }
private static string BuildReference(SolutionNode solution, ReferenceNode refr) { string ret = "<ProjectReference type=\""; if(solution.ProjectsTable.ContainsKey(refr.Name)) { ret += "Project\""; ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\" refto=\"" + refr.Name + "\" />"; } else { ProjectNode project = (ProjectNode)refr.Parent; string fileRef = FindFileReference(refr.Name, project); if(refr.Path != null || fileRef != null) { ret += "Assembly\" refto=\""; string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef; ret += finalPath; ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; return ret; } ret += "Gac\""; ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\""; ret += " refto=\""; try { Assembly assem = Assembly.LoadWithPartialName(refr.Name); ret += assem.FullName; } catch (System.NullReferenceException e) { e.ToString(); ret += refr.Name; } ret += "\" />"; } return ret; }
private void WriteProjectFiles(StreamWriter f, SolutionNode solution, ProjectNode project) { // Write list of source code files f.WriteLine("SOURCES_{0} = \\", project.Name); foreach (string file in project.Files) if (project.Files.GetBuildAction(file) == BuildAction.Compile) f.WriteLine("\t{0} \\", NicePath(project, file)); f.WriteLine(); // Write list of resource files f.WriteLine("RESOURCES_{0} = \\", project.Name); foreach (string file in project.Files) if (project.Files.GetBuildAction(file) == BuildAction.EmbeddedResource) { string path = NicePath(project, file); f.WriteLine("\t-resource:{0},{1} \\", path, Path.GetFileName(path)); } f.WriteLine(); // There's also Content and None in BuildAction. // What am I supposed to do with that? }
private void WriteProject(SolutionNode solution, ProjectNode project) { string csComp = "Mcs"; string netRuntime = "Mono"; if(project.Runtime == ClrRuntime.Microsoft) { csComp = "Csc"; netRuntime = "MsNet"; } string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp"); StreamWriter ss = new StreamWriter(projFile); m_Kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); using(ss) { ss.WriteLine( "<Project name=\"{0}\" description=\"\" standardNamespace=\"{1}\" newfilesearch=\"None\" enableviewstate=\"True\" fileversion=\"2.0\" language=\"C#\" clr-version=\"Net_2_0\" ctype=\"DotNetProject\">", project.Name, project.RootNamespace ); int count = 0; ss.WriteLine(" <Configurations active=\"{0}\">", solution.ActiveConfig); foreach(ConfigurationNode conf in project.Configurations) { ss.WriteLine(" <Configuration name=\"{0}\" ctype=\"DotNetProjectConfiguration\">", conf.Name); ss.Write(" <Output"); ss.Write(" directory=\"{0}\"", Helper.EndPath(Helper.NormalizePath(".\\" + conf.Options["OutputPath"].ToString()))); ss.Write(" assembly=\"{0}\"", project.AssemblyName); ss.Write(" executeScript=\"{0}\"", conf.Options["RunScript"]); //ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]); //ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]); if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0) { ss.Write(" executeBeforeBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString())); } else { ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]); } if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0) { ss.Write(" executeAfterBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString())); } else { ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]); } ss.Write(" executeBeforeBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]); ss.Write(" executeAfterBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]); ss.WriteLine(" />"); ss.Write(" <Build"); ss.Write(" debugmode=\"True\""); if (project.Type == ProjectType.WinExe) { ss.Write(" target=\"{0}\"", ProjectType.Exe.ToString()); } else { ss.Write(" target=\"{0}\"", project.Type); } ss.WriteLine(" />"); ss.Write(" <Execution"); ss.Write(" runwithwarnings=\"{0}\"", !conf.Options.WarningsAsErrors); ss.Write(" consolepause=\"True\""); ss.Write(" runtime=\"{0}\"", netRuntime); ss.Write(" clr-version=\"Net_2_0\""); ss.WriteLine(" />"); ss.Write(" <CodeGeneration"); ss.Write(" compiler=\"{0}\"", csComp); ss.Write(" warninglevel=\"{0}\"", conf.Options["WarningLevel"]); ss.Write(" nowarn=\"{0}\"", conf.Options["SuppressWarnings"]); ss.Write(" includedebuginformation=\"{0}\"", conf.Options["DebugInformation"]); ss.Write(" optimize=\"{0}\"", conf.Options["OptimizeCode"]); ss.Write(" unsafecodeallowed=\"{0}\"", conf.Options["AllowUnsafe"]); ss.Write(" generateoverflowchecks=\"{0}\"", conf.Options["CheckUnderflowOverflow"]); ss.Write(" mainclass=\"{0}\"", project.StartupObject); ss.Write(" target=\"{0}\"", project.Type); ss.Write(" definesymbols=\"{0}\"", conf.Options["CompilerDefines"]); ss.Write(" generatexmldocumentation=\"{0}\"", GenerateXmlDocFile(project, conf)); ss.Write(" win32Icon=\"{0}\"", project.AppIcon); ss.Write(" ctype=\"CSharpCompilerParameters\""); ss.WriteLine(" />"); ss.WriteLine(" </Configuration>"); count++; } ss.WriteLine(" </Configurations>"); ss.Write(" <DeploymentInformation"); ss.Write(" target=\"\""); ss.Write(" script=\"\""); ss.Write(" strategy=\"File\""); ss.WriteLine(">"); ss.WriteLine(" <excludeFiles />"); ss.WriteLine(" </DeploymentInformation>"); ss.WriteLine(" <Contents>"); foreach(string file in project.Files) { string buildAction = "Compile"; switch(project.Files.GetBuildAction(file)) { case BuildAction.None: buildAction = "Nothing"; break; case BuildAction.Content: buildAction = "Exclude"; break; case BuildAction.EmbeddedResource: buildAction = "EmbedAsResource"; break; default: buildAction = "Compile"; break; } // Sort of a hack, we try and resolve the path and make it relative, if we can. string filePath = PrependPath(file); ss.WriteLine(" <File name=\"{0}\" subtype=\"Code\" buildaction=\"{1}\" dependson=\"\" data=\"\" />", filePath, buildAction); } ss.WriteLine(" </Contents>"); ss.WriteLine(" <References>"); foreach(ReferenceNode refr in project.References) { ss.WriteLine(" {0}", BuildReference(solution, refr)); } ss.WriteLine(" </References>"); ss.WriteLine("</Project>"); } m_Kernel.CurrentWorkingDirectory.Pop(); }
private void CleanSolution(SolutionNode solution) { m_Kernel.Log.Write("Cleaning Autotools make files for", solution.Name); string slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am"); Helper.DeleteIfExists(slnFile); slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "in"); Helper.DeleteIfExists(slnFile); slnFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac"); Helper.DeleteIfExists(slnFile); slnFile = Helper.MakeFilePath(solution.FullPath, "configure"); Helper.DeleteIfExists(slnFile); slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile"); Helper.DeleteIfExists(slnFile); foreach (ProjectNode project in solution.Projects) { CleanProject(project); } m_Kernel.Log.Write(""); }
private void WriteProject(SolutionNode solution, ProjectNode project) { string solutionDir = Path.Combine(solution.FullPath, Path.Combine("autotools", solution.Name)); string projectDir = Path.Combine(solutionDir, project.Name); string projectVersion = project.Version; bool hasAssemblyConfig = false; chkMkDir(projectDir); List<string> compiledFiles = new List<string>(), contentFiles = new List<string>(), embeddedFiles = new List<string>(), binaryLibs = new List<string>(), pkgLibs = new List<string>(), systemLibs = new List<string>(), runtimeLibs = new List<string>(), extraDistFiles = new List<string>(), localCopyTargets = new List<string>(); // If there exists a .config file for this assembly, copy // it to the project folder // TODO: Support copying .config.osx files // TODO: support processing the .config file for native library deps string projectAssemblyName = project.Name; if (project.AssemblyName != null) projectAssemblyName = project.AssemblyName; if (File.Exists(Path.Combine(project.FullPath, projectAssemblyName) + ".dll.config")) { hasAssemblyConfig = true; System.IO.File.Copy(Path.Combine(project.FullPath, projectAssemblyName + ".dll.config"), Path.Combine(projectDir, projectAssemblyName + ".dll.config"), true); extraDistFiles.Add(project.AssemblyName + ".dll.config"); } foreach (ConfigurationNode conf in project.Configurations) { if (conf.Options.KeyFile != string.Empty) { // Copy snk file into the project's directory // Use the snk from the project directory directly string source = Path.Combine(project.FullPath, conf.Options.KeyFile); string keyFile = conf.Options.KeyFile; Regex re = new Regex(".*/"); keyFile = re.Replace(keyFile, ""); string dest = Path.Combine(projectDir, keyFile); // Tell the user if there's a problem copying the file try { mkdirDashP(System.IO.Path.GetDirectoryName(dest)); System.IO.File.Copy(source, dest, true); } catch (System.IO.IOException e) { Console.WriteLine(e.Message); } } } // Copy compiled, embedded and content files into the project's directory foreach (string filename in project.Files) { string source = Path.Combine(project.FullPath, filename); string dest = Path.Combine(projectDir, filename); if (filename.Contains("AssemblyInfo.cs")) { // If we've got an AssemblyInfo.cs, pull the version number from it string[] sources = { source }; string[] args = { "" }; Microsoft.CSharp.CSharpCodeProvider cscp = new Microsoft.CSharp.CSharpCodeProvider(); string tempAssemblyFile = Path.Combine(Path.GetTempPath(), project.Name + "-temp.dll"); System.CodeDom.Compiler.CompilerParameters cparam = new System.CodeDom.Compiler.CompilerParameters(args, tempAssemblyFile); System.CodeDom.Compiler.CompilerResults cr = cscp.CompileAssemblyFromFile(cparam, sources); foreach (System.CodeDom.Compiler.CompilerError error in cr.Errors) Console.WriteLine("Error! '{0}'", error.ErrorText); try { string projectFullName = cr.CompiledAssembly.FullName; Regex verRegex = new Regex("Version=([\\d\\.]+)"); Match verMatch = verRegex.Match(projectFullName); if (verMatch.Success) projectVersion = verMatch.Groups[1].Value; }catch{ Console.WriteLine("Couldn't compile AssemblyInfo.cs"); } // Clean up the temp file try { if (File.Exists(tempAssemblyFile)) File.Delete(tempAssemblyFile); } catch { Console.WriteLine("Error! '{0}'", e); } } // Tell the user if there's a problem copying the file try { mkdirDashP(System.IO.Path.GetDirectoryName(dest)); System.IO.File.Copy(source, dest, true); } catch (System.IO.IOException e) { Console.WriteLine(e.Message); } switch (project.Files.GetBuildAction(filename)) { case BuildAction.Compile: compiledFiles.Add(filename); break; case BuildAction.Content: contentFiles.Add(filename); extraDistFiles.Add(filename); break; case BuildAction.EmbeddedResource: embeddedFiles.Add(filename); break; } } // Set up references for (int refNum = 0; refNum < project.References.Count; refNum++) { ReferenceNode refr = project.References[refNum]; Assembly refAssembly = Assembly.LoadWithPartialName(refr.Name); /* Determine which pkg-config (.pc) file refers to this assembly */ SystemPackage package = null; if (packagesHash.ContainsKey(refr.Name)) { package = packagesHash[refr.Name]; } else { string assemblyFullName = string.Empty; if (refAssembly != null) assemblyFullName = refAssembly.FullName; string assemblyFileName = string.Empty; if (assemblyFullName != string.Empty && assemblyFullNameToPath.ContainsKey(assemblyFullName) ) assemblyFileName = assemblyFullNameToPath[assemblyFullName]; if (assemblyFileName != string.Empty && assemblyPathToPackage.ContainsKey(assemblyFileName) ) package = assemblyPathToPackage[assemblyFileName]; } /* If we know the .pc file and it is not "mono" (already in the path), add a -pkg: argument */ if (package != null && package.Name != "mono" && !pkgLibs.Contains(package.Name) ) pkgLibs.Add(package.Name); string fileRef = FindFileReference(refr.Name, (ProjectNode)refr.Parent); if (refr.LocalCopy || solution.ProjectsTable.ContainsKey(refr.Name) || fileRef != null || refr.Path != null ) { /* Attempt to copy the referenced lib to the project's directory */ string filename = refr.Name + ".dll"; string source = filename; if (refr.Path != null) source = Path.Combine(refr.Path, source); source = Path.Combine(project.FullPath, source); string dest = Path.Combine(projectDir, filename); /* Since we depend on this binary dll to build, we * will add a compile- time dependency on the * copied dll, and add the dll to the list of * files distributed with this package */ binaryLibs.Add(refr.Name + ".dll"); extraDistFiles.Add(refr.Name + ".dll"); // TODO: Support copying .config.osx files // TODO: Support for determining native dependencies if (File.Exists(source + ".config")) { System.IO.File.Copy(source + ".config", Path.GetDirectoryName(dest), true); extraDistFiles.Add(refr.Name + ".dll.config"); } try { System.IO.File.Copy(source, dest, true); } catch (System.IO.IOException) { if (solution.ProjectsTable.ContainsKey(refr.Name)){ /* If an assembly is referenced, marked for * local copy, in the list of projects for * this solution, but does not exist, put a * target into the Makefile.am to build the * assembly and copy it to this project's * directory */ ProjectNode sourcePrj = ((solution.ProjectsTable[refr.Name])); string target = String.Format("{0}:\n" + "\t$(MAKE) -C ../{1}\n" + "\tln ../{2}/$@ $@\n", filename, sourcePrj.Name, sourcePrj.Name ); localCopyTargets.Add(target); } } } else if( !pkgLibs.Contains(refr.Name) ) { // Else, let's assume it's in the GAC or the lib path string assemName = string.Empty; int index = refr.Name.IndexOf(","); if (index > 0) assemName = refr.Name.Substring(0, index); else assemName = refr.Name; m_Kernel.Log.Write(String.Format( "Warning: Couldn't find an appropriate assembly " + "for reference:\n'{0}'", refr.Name )); systemLibs.Add(assemName); } } const string lineSep = " \\\n\t"; string compiledFilesString = string.Empty; if (compiledFiles.Count > 0) compiledFilesString = lineSep + string.Join(lineSep, compiledFiles.ToArray()); string embeddedFilesString = ""; if (embeddedFiles.Count > 0) embeddedFilesString = lineSep + string.Join(lineSep, embeddedFiles.ToArray()); string contentFilesString = ""; if (contentFiles.Count > 0) contentFilesString = lineSep + string.Join(lineSep, contentFiles.ToArray()); string extraDistFilesString = ""; if (extraDistFiles.Count > 0) extraDistFilesString = lineSep + string.Join(lineSep, extraDistFiles.ToArray()); string pkgLibsString = ""; if (pkgLibs.Count > 0) pkgLibsString = lineSep + string.Join(lineSep, pkgLibs.ToArray()); string binaryLibsString = ""; if (binaryLibs.Count > 0) binaryLibsString = lineSep + string.Join(lineSep, binaryLibs.ToArray()); string systemLibsString = ""; if (systemLibs.Count > 0) systemLibsString = lineSep + string.Join(lineSep, systemLibs.ToArray()); string localCopyTargetsString = ""; if (localCopyTargets.Count > 0) localCopyTargetsString = string.Join("\n", localCopyTargets.ToArray()); string monoPath = ""; foreach (string runtimeLib in runtimeLibs) { monoPath += ":`pkg-config --variable=libdir " + runtimeLib + "`"; } // Add the project name to the list of transformation // parameters XsltArgumentList argList = new XsltArgumentList(); argList.AddParam("projectName", "", project.Name); argList.AddParam("solutionName", "", solution.Name); argList.AddParam("assemblyName", "", projectAssemblyName); argList.AddParam("compiledFiles", "", compiledFilesString); argList.AddParam("embeddedFiles", "", embeddedFilesString); argList.AddParam("contentFiles", "", contentFilesString); argList.AddParam("extraDistFiles", "", extraDistFilesString); argList.AddParam("pkgLibs", "", pkgLibsString); argList.AddParam("binaryLibs", "", binaryLibsString); argList.AddParam("systemLibs", "", systemLibsString); argList.AddParam("monoPath", "", monoPath); argList.AddParam("localCopyTargets", "", localCopyTargetsString); argList.AddParam("projectVersion", "", projectVersion); argList.AddParam("hasAssemblyConfig", "", hasAssemblyConfig ? "true" : ""); // Transform the templates transformToFile(Path.Combine(projectDir, "configure.ac"), argList, "/Autotools/ProjectConfigureAc"); transformToFile(Path.Combine(projectDir, "Makefile.am"), argList, "/Autotools/ProjectMakefileAm"); transformToFile(Path.Combine(projectDir, "autogen.sh"), argList, "/Autotools/ProjectAutogenSh"); if (project.Type == Core.Nodes.ProjectType.Library) transformToFile(Path.Combine(projectDir, project.Name + ".pc.in"), argList, "/Autotools/ProjectPcIn"); if (project.Type == Core.Nodes.ProjectType.Exe || project.Type == Core.Nodes.ProjectType.WinExe) transformToFile(Path.Combine(projectDir, project.Name.ToLower() + ".in"), argList, "/Autotools/ProjectWrapperScriptIn"); }
private void WriteCombine(SolutionNode solution) { #region "Create Solution directory if it doesn't exist" string solutionDir = Path.Combine(solution.FullPath, Path.Combine("autotools", solution.Name)); chkMkDir(solutionDir); #endregion #region "Write Solution-level files" XsltArgumentList argList = new XsltArgumentList(); argList.AddParam("solutionName", "", solution.Name); // $solutionDir is $rootDir/$solutionName/ transformToFile(Path.Combine(solutionDir, "configure.ac"), argList, "/Autotools/SolutionConfigureAc"); transformToFile(Path.Combine(solutionDir, "Makefile.am"), argList, "/Autotools/SolutionMakefileAm"); transformToFile(Path.Combine(solutionDir, "autogen.sh"), argList, "/Autotools/SolutionAutogenSh"); #endregion foreach (ProjectNode project in solution.ProjectsTableOrder) { m_Kernel.Log.Write(String.Format("Writing project: {0}", project.Name)); WriteProject(solution, project); } }
private void CleanSolution(SolutionNode solution) { m_Kernel.Log.Write("Cleaning SharpDevelop combine and project files for", solution.Name); string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx"); Helper.DeleteIfExists(slnFile); foreach(ProjectNode project in solution.Projects) { CleanProject(project); } m_Kernel.Log.Write(""); }
private void WriteSolution(SolutionNode solution) { kernel.Log.Write("Creating {0} solution and project files", this.VersionName); foreach (ProjectNode project in solution.Projects) { kernel.Log.Write("...Creating project: {0}", project.Name); WriteProject(solution, project); } kernel.Log.Write(""); string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); StreamWriter ss = new StreamWriter(solutionFile); kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); using (ss) { ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion); ss.WriteLine("# Visual Studio 2005"); foreach (ProjectNode project in solution.Projects) { if (!tools.ContainsKey(project.Language)) { throw new UnknownLanguageException("Unknown .NET language: " + project.Language); } ToolInfo toolInfo = (ToolInfo)tools[project.Language]; string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"", toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name, toolInfo.FileExtension), project.Guid.ToString().ToUpper()); //ss.WriteLine(" ProjectSection(ProjectDependencies) = postProject"); //ss.WriteLine(" EndProjectSection"); ss.WriteLine("EndProject"); } if (solution.Files != null) { ss.WriteLine("Project(\"{0}\") = \"Solution Items\", \"Solution Items\", \"{1}\"", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", "{468F1D07-AD17-4CC3-ABD0-2CA268E4E1A6}"); ss.WriteLine("\tProjectSection(SolutionItems) = preProject"); foreach (string file in solution.Files) ss.WriteLine("\t\t{0} = {0}", file); ss.WriteLine("\tEndProjectSection"); ss.WriteLine("EndProject"); } ss.WriteLine("Global"); ss.WriteLine(" GlobalSection(SolutionConfigurationPlatforms) = preSolution"); foreach (ConfigurationNode conf in solution.Configurations) { ss.WriteLine(" {0}|Any CPU = {0}|Any CPU", conf.Name); } ss.WriteLine(" EndGlobalSection"); if (solution.Projects.Count > 1) { ss.WriteLine(" GlobalSection(ProjectDependencies) = postSolution"); } foreach (ProjectNode project in solution.Projects) { for (int i = 0; i < project.References.Count; i++) { ReferenceNode refr = (ReferenceNode)project.References[i]; if (solution.ProjectsTable.ContainsKey(refr.Name)) { ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; ss.WriteLine(" ({{{0}}}).{1} = ({{{2}}})", project.Guid.ToString().ToUpper() , i, refProject.Guid.ToString().ToUpper() ); } } } if (solution.Projects.Count > 1) { ss.WriteLine(" EndGlobalSection"); } ss.WriteLine(" GlobalSection(ProjectConfigurationPlatforms) = postSolution"); foreach (ProjectNode project in solution.Projects) { foreach (ConfigurationNode conf in solution.Configurations) { ss.WriteLine(" {{{0}}}.{1}|Any CPU.ActiveCfg = {1}|Any CPU", project.Guid.ToString().ToUpper(), conf.Name); ss.WriteLine(" {{{0}}}.{1}|Any CPU.Build.0 = {1}|Any CPU", project.Guid.ToString().ToUpper(), conf.Name); } } ss.WriteLine(" EndGlobalSection"); ss.WriteLine(" GlobalSection(SolutionProperties) = preSolution"); ss.WriteLine(" HideSolutionNode = FALSE"); ss.WriteLine(" EndGlobalSection"); ss.WriteLine("EndGlobal"); } kernel.CurrentWorkingDirectory.Pop(); }
private void CleanSolution(SolutionNode solution) { kernel.Log.Write("Cleaning {0} solution and project files", this.VersionName, solution.Name); string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); Helper.DeleteIfExists(slnFile); Helper.DeleteIfExists(suoFile); foreach (ProjectNode project in solution.Projects) { CleanProject(project); } kernel.Log.Write(""); }
private void CleanSolution(SolutionNode solution) { m_Kernel.Log.Write("Cleaning makefile for {0}", solution.Name); string file = Helper.MakeFilePath(solution.FullPath, solution.Name, "make"); Helper.DeleteIfExists(file); m_Kernel.Log.Write(""); }
private void WriteCombine(SolutionNode solution) { m_Kernel.Log.Write("Creating NAnt build files"); foreach (ProjectNode project in solution.Projects) { if (m_Kernel.AllowProject(project.FilterGroups)) { m_Kernel.Log.Write("...Creating project: {0}", project.Name); WriteProject(solution, project); } } m_Kernel.Log.Write(""); string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); StreamWriter ss = new StreamWriter(combFile); m_Kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); using (ss) { ss.WriteLine("<?xml version=\"1.0\" ?>"); ss.WriteLine("<project name=\"{0}\" default=\"build\">", solution.Name); ss.WriteLine(" <echo message=\"Using '${nant.settings.currentframework}' Framework\"/>"); ss.WriteLine(); //ss.WriteLine(" <property name=\"dist.dir\" value=\"dist\" />"); //ss.WriteLine(" <property name=\"source.dir\" value=\"source\" />"); ss.WriteLine(" <property name=\"bin.dir\" value=\"bin\" />"); ss.WriteLine(" <property name=\"obj.dir\" value=\"obj\" />"); ss.WriteLine(" <property name=\"doc.dir\" value=\"doc\" />"); ss.WriteLine(" <property name=\"project.main.dir\" value=\"${project::get-base-directory()}\" />"); // Use the active configuration, which is the first configuration name in the prebuild file. Dictionary<string,string> emittedConfigurations = new Dictionary<string, string>(); ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", solution.ActiveConfig); ss.WriteLine(); foreach (ConfigurationNode conf in solution.Configurations) { // If the name isn't in the emitted configurations, we give a high level target to the // platform specific on. This lets "Debug" point to "Debug-AnyCPU". if (!emittedConfigurations.ContainsKey(conf.Name)) { // Add it to the dictionary so we only emit one. emittedConfigurations.Add(conf.Name, conf.Platform); // Write out the target block. ss.WriteLine(" <target name=\"{0}\" description=\"{0}|{1}\" depends=\"{0}-{1}\">", conf.Name, conf.Platform); ss.WriteLine(" </target>"); ss.WriteLine(); } // Write out the target for the configuration. ss.WriteLine(" <target name=\"{0}-{1}\" description=\"{0}|{1}\">", conf.Name, conf.Platform); ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name); ss.WriteLine(" <property name=\"build.debug\" value=\"{0}\" />", conf.Options["DebugInformation"].ToString().ToLower()); ss.WriteLine("\t\t <property name=\"build.platform\" value=\"{0}\" />", conf.Platform); ss.WriteLine(" </target>"); ss.WriteLine(); } ss.WriteLine(" <target name=\"net-1.1\" description=\"Sets framework to .NET 1.1\">"); ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-1.1\" />"); ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine(" <target name=\"net-2.0\" description=\"Sets framework to .NET 2.0\">"); ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-2.0\" />"); ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine(" <target name=\"net-3.5\" description=\"Sets framework to .NET 3.5\">"); ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-3.5\" />"); ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine(" <target name=\"mono-1.0\" description=\"Sets framework to mono 1.0\">"); ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-1.0\" />"); ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine(" <target name=\"mono-2.0\" description=\"Sets framework to mono 2.0\">"); ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-2.0\" />"); ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine(" <target name=\"mono-3.5\" description=\"Sets framework to mono 3.5\">"); ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-3.5\" />"); ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine(" <target name=\"init\" description=\"\">"); ss.WriteLine(" <call target=\"${project.config}\" />"); ss.WriteLine(" <property name=\"sys.os.platform\""); ss.WriteLine(" value=\"${platform::get-name()}\""); ss.WriteLine(" />"); ss.WriteLine(" <echo message=\"Platform ${sys.os.platform}\" />"); ss.WriteLine(" <property name=\"build.dir\" value=\"${bin.dir}/${project.config}\" />"); ss.WriteLine(" </target>"); ss.WriteLine(); // sdague - ok, this is an ugly hack, but what it lets // us do is native include of files into the nant // created files from all .nant/*include files. This // lets us keep using prebuild, but allows for // extended nant targets to do build and the like. try { Regex re = new Regex(".include$"); DirectoryInfo nantdir = new DirectoryInfo(".nant"); foreach (FileSystemInfo item in nantdir.GetFileSystemInfos()) { if (item is DirectoryInfo) { } else if (item is FileInfo) { if (re.Match(item.FullName) != System.Text.RegularExpressions.Match.Empty) { Console.WriteLine("Including file: " + item.FullName); using (FileStream fs = new FileStream(item.FullName, FileMode.Open, FileAccess.Read, FileShare.None)) { using (StreamReader sr = new StreamReader(fs)) { ss.WriteLine("<!-- included from {0} -->", (item).FullName); while (sr.Peek() != -1) { ss.WriteLine(sr.ReadLine()); } ss.WriteLine(); } } } } } } catch { } // ss.WriteLine(" <include buildfile=\".nant/local.include\" />"); // ss.WriteLine(" <target name=\"zip\" description=\"\">"); // ss.WriteLine(" <zip zipfile=\"{0}-{1}.zip\">", solution.Name, solution.Version); // ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">"); // ss.WriteLine(" <include name=\"${project::get-base-directory()}/**/*.cs\" />"); // // ss.WriteLine(" <include name=\"${project.main.dir}/**/*\" />"); // ss.WriteLine(" </fileset>"); // ss.WriteLine(" </zip>"); // ss.WriteLine(" <echo message=\"Building zip target\" />"); // ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine(" <target name=\"clean\" description=\"\">"); ss.WriteLine(" <echo message=\"Deleting all builds from all configurations\" />"); //ss.WriteLine(" <delete dir=\"${dist.dir}\" failonerror=\"false\" />"); // justincc: FIXME FIXME FIXME - A temporary OpenSim hack to clean up files when "nant clean" is executed. // Should be replaced with extreme prejudice once anybody finds out if the CleanFiles stuff works or there is // another working mechanism for specifying this stuff ss.WriteLine(" <delete failonerror=\"false\">"); ss.WriteLine(" <fileset basedir=\"${bin.dir}\">"); ss.WriteLine(" <include name=\"OpenSim*.dll\"/>"); ss.WriteLine(" <include name=\"OpenSim*.dll.mdb\"/>"); ss.WriteLine(" <include name=\"OpenSim*.exe\"/>"); ss.WriteLine(" <include name=\"OpenSim*.exe.mdb\"/>"); ss.WriteLine(" <include name=\"ScriptEngines/*\"/>"); ss.WriteLine(" <include name=\"Physics/*.dll\"/>"); ss.WriteLine(" <include name=\"Physics/*.dll.mdb\"/>"); ss.WriteLine(" <exclude name=\"OpenSim.32BitLaunch.exe\"/>"); ss.WriteLine(" <exclude name=\"ScriptEngines/Default.lsl\"/>"); ss.WriteLine(" </fileset>"); ss.WriteLine(" </delete>"); if (solution.Cleanup != null && solution.Cleanup.CleanFiles.Count > 0) { foreach (CleanFilesNode cleanFile in solution.Cleanup.CleanFiles) { ss.WriteLine(" <delete failonerror=\"false\">"); ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">"); ss.WriteLine(" <include name=\"{0}/*\"/>", cleanFile.Pattern); ss.WriteLine(" <include name=\"{0}\"/>", cleanFile.Pattern); ss.WriteLine(" </fileset>"); ss.WriteLine(" </delete>"); } } ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />"); foreach (ProjectNode project in solution.Projects) { string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); ss.Write(" <nant buildfile=\"{0}\"", Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + GetProjectExtension(project), "build"), '/')); ss.WriteLine(" target=\"clean\" />"); } ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine(" <target name=\"build\" depends=\"init\" description=\"\">"); foreach (ProjectNode project in solution.ProjectsTableOrder) { string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); ss.Write(" <nant buildfile=\"{0}\"", Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + GetProjectExtension(project), "build"), '/')); ss.WriteLine(" target=\"build\" />"); } ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine(" <target name=\"build-release\" depends=\"Release, init, build\" description=\"Builds in Release mode\" />"); ss.WriteLine(); ss.WriteLine(" <target name=\"build-debug\" depends=\"Debug, init, build\" description=\"Builds in Debug mode\" />"); ss.WriteLine(); //ss.WriteLine(" <target name=\"package\" depends=\"clean, doc, copyfiles, zip\" description=\"Builds in Release mode\" />"); ss.WriteLine(" <target name=\"package\" depends=\"clean, doc\" description=\"Builds all\" />"); ss.WriteLine(); ss.WriteLine(" <target name=\"doc\" depends=\"build-release\">"); ss.WriteLine(" <echo message=\"Generating all documentation from all builds\" />"); foreach (ProjectNode project in solution.Projects) { string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); ss.Write(" <nant buildfile=\"{0}\"", Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + GetProjectExtension(project), "build"), '/')); ss.WriteLine(" target=\"doc\" />"); } ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine("</project>"); } m_Kernel.CurrentWorkingDirectory.Pop(); }
private void WriteProject(SolutionNode solution, ProjectNode project) { string projFile = Helper.MakeFilePath(project.FullPath, project.Name + GetProjectExtension(project), "build"); StreamWriter ss = new StreamWriter(projFile); m_Kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); bool hasDoc = false; using (ss) { ss.WriteLine("<?xml version=\"1.0\" ?>"); ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name); ss.WriteLine(" <target name=\"{0}\">", "build"); ss.WriteLine(" <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />"); ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />"); ss.Write(" <csc "); ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower()); ss.Write(" debug=\"{0}\"", "${build.debug}"); ss.Write(" platform=\"${build.platform}\""); foreach (ConfigurationNode conf in project.Configurations) { if (conf.Options.KeyFile != "") { ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile); break; } } foreach (ConfigurationNode conf in project.Configurations) { ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe); break; } foreach (ConfigurationNode conf in project.Configurations) { ss.Write(" warnaserror=\"{0}\"", conf.Options.WarningsAsErrors); break; } foreach (ConfigurationNode conf in project.Configurations) { ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines); break; } foreach (ConfigurationNode conf in project.Configurations) { ss.Write(" nostdlib=\"{0}\"", conf.Options["NoStdLib"]); break; } ss.Write(" main=\"{0}\"", project.StartupObject); foreach (ConfigurationNode conf in project.Configurations) { if (GetXmlDocFile(project, conf) != "") { ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf)); hasDoc = true; } break; } ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}"); if (project.Type == ProjectType.Library) { ss.Write(".dll\""); } else { ss.Write(".exe\""); } if (project.AppIcon != null && project.AppIcon.Length != 0) { ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon, '/')); } // This disables a very different behavior between VS and NAnt. With Nant, // If you have using System.Xml; it will ensure System.Xml.dll is referenced, // but not in VS. This will force the behaviors to match, so when it works // in nant, it will work in VS. ss.Write(" noconfig=\"true\""); ss.WriteLine(">"); ss.WriteLine(" <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace); foreach (string file in project.Files) { switch (project.Files.GetBuildAction(file)) { case BuildAction.EmbeddedResource: ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />"); break; default: if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) { ss.WriteLine(" <include name=\"{0}\" />", file.Substring(0, file.LastIndexOf('.')) + ".resx"); } break; } } //if (project.Files.GetSubType(file).ToString() != "Code") //{ // ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); ss.WriteLine(" </resources>"); ss.WriteLine(" <sources failonempty=\"true\">"); foreach (string file in project.Files) { switch (project.Files.GetBuildAction(file)) { case BuildAction.Compile: ss.WriteLine(" <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />"); break; default: break; } } ss.WriteLine(" </sources>"); ss.WriteLine(" <references basedir=\"${project::get-base-directory()}\">"); ss.WriteLine(" <lib>"); ss.WriteLine(" <include name=\"${project::get-base-directory()}\" />"); foreach(ReferencePathNode refPath in project.ReferencePaths) { ss.WriteLine(" <include name=\"${project::get-base-directory()}/" + refPath.Path.TrimEnd('/', '\\') + "\" />"); } ss.WriteLine(" </lib>"); foreach (ReferenceNode refr in project.References) { string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)), '/'); if (refr.Path != null) { if (ExtensionSpecified(refr.Name)) { ss.WriteLine (" <include name=\"" + path + refr.Name + "\"/>"); } else { ss.WriteLine (" <include name=\"" + path + refr.Name + ".dll\"/>"); } } else { ss.WriteLine (" <include name=\"" + path + "\" />"); } } ss.WriteLine(" </references>"); ss.WriteLine(" </csc>"); foreach (ConfigurationNode conf in project.Configurations) { if (!String.IsNullOrEmpty(conf.Options.OutputPath)) { string targetDir = Helper.NormalizePath(conf.Options.OutputPath, '/'); ss.WriteLine(" <echo message=\"Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/" + targetDir + "\" />"); ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/" + targetDir + "\"/>"); ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/" + targetDir + "\">"); ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}/${build.dir}/\" >"); ss.WriteLine(" <include name=\"*.dll\"/>"); ss.WriteLine(" <include name=\"*.exe\"/>"); ss.WriteLine(" <include name=\"*.mdb\" if='${build.debug}'/>"); ss.WriteLine(" <include name=\"*.pdb\" if='${build.debug}'/>"); ss.WriteLine(" </fileset>"); ss.WriteLine(" </copy>"); break; } } ss.WriteLine(" </target>"); ss.WriteLine(" <target name=\"clean\">"); ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />"); ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />"); ss.WriteLine(" </target>"); ss.WriteLine(" <target name=\"doc\" description=\"Creates documentation.\">"); if (hasDoc) { ss.WriteLine(" <property name=\"doc.target\" value=\"\" />"); ss.WriteLine(" <if test=\"${platform::is-unix()}\">"); ss.WriteLine(" <property name=\"doc.target\" value=\"Web\" />"); ss.WriteLine(" </if>"); ss.WriteLine(" <ndoc failonerror=\"false\" verbose=\"true\">"); ss.WriteLine(" <assemblies basedir=\"${project::get-base-directory()}\">"); ss.Write(" <include name=\"${build.dir}/${project::get-name()}"); if (project.Type == ProjectType.Library) { ss.WriteLine(".dll\" />"); } else { ss.WriteLine(".exe\" />"); } ss.WriteLine(" </assemblies>"); ss.WriteLine(" <summaries basedir=\"${project::get-base-directory()}\">"); ss.WriteLine(" <include name=\"${build.dir}/${project::get-name()}.xml\"/>"); ss.WriteLine(" </summaries>"); ss.WriteLine(" <referencepaths basedir=\"${project::get-base-directory()}\">"); ss.WriteLine(" <include name=\"${build.dir}\" />"); // foreach(ReferenceNode refr in project.References) // { // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/'); // if (path != "") // { // ss.WriteLine(" <include name=\"{0}\" />", path); // } // } ss.WriteLine(" </referencepaths>"); ss.WriteLine(" <documenters>"); ss.WriteLine(" <documenter name=\"MSDN\">"); ss.WriteLine(" <property name=\"OutputDirectory\" value=\"${project::get-base-directory()}/${build.dir}/doc/${project::get-name()}\" />"); ss.WriteLine(" <property name=\"OutputTarget\" value=\"${doc.target}\" />"); ss.WriteLine(" <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />"); ss.WriteLine(" <property name=\"IncludeFavorites\" value=\"False\" />"); ss.WriteLine(" <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />"); ss.WriteLine(" <property name=\"SplitTOCs\" value=\"False\" />"); ss.WriteLine(" <property name=\"DefaulTOC\" value=\"\" />"); ss.WriteLine(" <property name=\"ShowVisualBasic\" value=\"True\" />"); ss.WriteLine(" <property name=\"AutoDocumentConstructors\" value=\"True\" />"); ss.WriteLine(" <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />"); ss.WriteLine(" <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />"); ss.WriteLine(" <property name=\"ShowMissingParams\" value=\"${build.debug}\" />"); ss.WriteLine(" <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />"); ss.WriteLine(" <property name=\"ShowMissingValues\" value=\"${build.debug}\" />"); ss.WriteLine(" <property name=\"DocumentInternals\" value=\"False\" />"); ss.WriteLine(" <property name=\"DocumentPrivates\" value=\"False\" />"); ss.WriteLine(" <property name=\"DocumentProtected\" value=\"True\" />"); ss.WriteLine(" <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />"); ss.WriteLine(" <property name=\"IncludeAssemblyVersion\" value=\"True\" />"); ss.WriteLine(" </documenter>"); ss.WriteLine(" </documenters>"); ss.WriteLine(" </ndoc>"); } ss.WriteLine(" </target>"); ss.WriteLine("</project>"); } m_Kernel.CurrentWorkingDirectory.Pop(); }
private void WriteProject(SolutionNode solution, ProjectNode project) { string projFile = Helper.MakeFilePath(project.FullPath, "Include", "am"); StreamWriter ss = new StreamWriter(projFile); ss.NewLine = "\n"; m_Kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); using(ss) { ss.WriteLine(Helper.AssemblyFullName(project.AssemblyName, project.Type) + ":"); ss.WriteLine("\tmkdir -p " + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/"); foreach(string file in project.Files) { if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) { ss.Write("\tresgen "); ss.Write(Helper.NormalizePath(Path.Combine(project.Path, file.Substring(0, file.LastIndexOf('.')) + ".resx "), '/')); if (project.Files.GetResourceName(file) != "") { ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/')); } else { ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/')); } } } ss.WriteLine("\t$(CSC)\t/out:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " \\"); ss.WriteLine("\t\t/target:" + project.Type.ToString().ToLower() + " \\"); if (project.References.Count > 0) { ss.Write("\t\t/reference:"); bool firstref = true; foreach(ReferenceNode refr in project.References) { if (firstref) { firstref = false; } else { ss.Write(","); } ss.Write("{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(solution.FullPath, BuildReference(solution, refr)), '/')); } ss.WriteLine(" \\"); } //ss.WriteLine("\t\tProperties/AssemblyInfo.cs \\"); foreach(string file in project.Files) { switch(project.Files.GetBuildAction(file)) { case BuildAction.EmbeddedResource: ss.Write("\t\t/resource:"); ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, file), '/') + " \\"); break; default: if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) { ss.Write("\t\t/resource:"); if (project.Files.GetResourceName(file) != "") { ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/') + "," + project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources" + " \\"); } else { ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/') + "," + project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources" + " \\"); } } break; } } foreach(ConfigurationNode conf in project.Configurations) { if (conf.Options.KeyFile !="") { ss.WriteLine("\t\t/keyfile:" + Helper.NormalizePath(Path.Combine(project.Path, conf.Options.KeyFile), '/') + " \\"); break; } } foreach(ConfigurationNode conf in project.Configurations) { if (conf.Options.AllowUnsafe) { ss.WriteLine("\t\t/unsafe \\"); break; } } if (project.AppIcon != "") { ss.WriteLine("\t\t/win32icon:" + Helper.NormalizePath(Path.Combine(project.Path, project.AppIcon), '/') + " \\"); } foreach(ConfigurationNode conf in project.Configurations) { ss.WriteLine("\t\t/define:{0}", conf.Options.CompilerDefines.Replace(';', ',') + " \\"); break; } foreach(ConfigurationNode conf in project.Configurations) { if (GetXmlDocFile(project, conf) !="") { ss.WriteLine("\t\t/doc:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + project.Name + ".xml \\"); break; } } foreach(string file in project.Files) { switch(project.Files.GetBuildAction(file)) { case BuildAction.Compile: ss.WriteLine("\t\t\\"); ss.Write("\t\t" + NormalizePath(Path.Combine(Helper.MakePathRelativeTo(solution.FullPath, project.Path), file))); break; default: break; } } ss.WriteLine(); ss.WriteLine(); if (project.Type == ProjectType.Library) { ss.WriteLine("install-data-local:"); ss.WriteLine(" echo \"$(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS)\"; \\"); ss.WriteLine(" $(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS) || exit 1;"); ss.WriteLine(); ss.WriteLine("uninstall-local:"); ss.WriteLine(" echo \"$(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS)\"; \\"); ss.WriteLine(" $(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS) || exit 1;"); ss.WriteLine(); } ss.WriteLine("CLEANFILES = $(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " $(BUILD_DIR)/$(CONFIG)/" + project.AssemblyName + ".mdb $(BUILD_DIR)/$(CONFIG)/" + project.AssemblyName + ".pdb " + project.AssemblyName + ".xml"); ss.WriteLine("EXTRA_DIST = \\"); ss.Write(" $(FILES)"); foreach(ConfigurationNode conf in project.Configurations) { if (conf.Options.KeyFile != "") { ss.Write(" \\"); ss.WriteLine("\t" + conf.Options.KeyFile); } break; } } m_Kernel.CurrentWorkingDirectory.Pop(); }
private void WriteCombine(SolutionNode solution) { /* TODO: These vars should be pulled from the prebuild.xml file */ string releaseVersion = "2.0.0"; string assemblyVersion = "2.1.0.0"; string description = "Tao Framework " + solution.Name + " Binding For .NET"; hasLibrary = false; m_Kernel.Log.Write("Creating Autotools make files"); foreach(ProjectNode project in solution.Projects) { if(m_Kernel.AllowProject(project.FilterGroups)) { m_Kernel.Log.Write("...Creating makefile: {0}", project.Name); WriteProject(solution, project); } } m_Kernel.Log.Write(""); string combFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am"); StreamWriter ss = new StreamWriter(combFile); ss.NewLine = "\n"; m_Kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); using(ss) { foreach(ProjectNode project in solution.ProjectsTableOrder) { if (project.Type == ProjectType.Library) { hasLibrary = true; break; } } if (hasLibrary) { ss.Write("pkgconfig_in_files = "); foreach(ProjectNode project in solution.ProjectsTableOrder) { if (project.Type == ProjectType.Library) { string combFilepc = Helper.MakeFilePath(solution.FullPath, project.Name, "pc.in"); ss.Write(" " + project.Name + ".pc.in "); StreamWriter sspc = new StreamWriter(combFilepc); sspc.NewLine = "\n"; using(sspc) { sspc.WriteLine("prefix=@prefix@"); sspc.WriteLine("exec_prefix=${prefix}"); sspc.WriteLine("libdir=${exec_prefix}/lib"); sspc.WriteLine(); sspc.WriteLine("Name: @PACKAGE_NAME@"); sspc.WriteLine("Description: @DESCRIPTION@"); sspc.WriteLine("Version: @ASSEMBLY_VERSION@"); sspc.WriteLine("Libs: -r:${libdir}/mono/gac/@PACKAGE_NAME@/@ASSEMBLY_VERSION@__@PUBKEY@/@[email protected]"); } } } ss.WriteLine(); ss.WriteLine("pkgconfigdir=$(prefix)/lib/pkgconfig"); ss.WriteLine("pkgconfig_DATA=$(pkgconfig_in_files:.pc.in=.pc)"); } ss.WriteLine(); foreach(ProjectNode project in solution.ProjectsTableOrder) { string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); ss.WriteLine("-include x {0}", Helper.NormalizePath(Helper.MakeFilePath(path, "Include", "am"),'/')); } ss.WriteLine(); ss.WriteLine("all: \\"); ss.Write("\t"); foreach(ProjectNode project in solution.ProjectsTableOrder) { string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); ss.Write(Helper.AssemblyFullName(project.AssemblyName, project.Type) + " "); } ss.WriteLine(); if (hasLibrary) { ss.WriteLine("EXTRA_DIST = \\"); ss.WriteLine("\t$(pkgconfig_in_files)"); } else { ss.WriteLine("EXTRA_DIST = "); } ss.WriteLine(); ss.WriteLine("DISTCLEANFILES = \\"); ss.WriteLine("\tconfigure \\"); ss.WriteLine("\tMakefile.in \\"); ss.WriteLine("\taclocal.m4"); } combFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac"); StreamWriter ts = new StreamWriter(combFile); ts.NewLine = "\n"; using(ts) { if (this.hasLibrary) { foreach(ProjectNode project in solution.ProjectsTableOrder) { if (project.Type == ProjectType.Library) { ts.WriteLine("AC_INIT(" + project.Name + ".pc.in)"); break; } } } else { ts.WriteLine("AC_INIT(Makefile.am)"); } ts.WriteLine("AC_PREREQ(2.53)"); ts.WriteLine("AC_CANONICAL_SYSTEM"); ts.WriteLine("PACKAGE_NAME={0}", solution.Name); ts.WriteLine("PACKAGE_VERSION={0}", releaseVersion); ts.WriteLine("DESCRIPTION=\"{0}\"", description); ts.WriteLine("AC_SUBST(DESCRIPTION)"); ts.WriteLine("AM_INIT_AUTOMAKE([$PACKAGE_NAME],[$PACKAGE_VERSION],[$DESCRIPTION])"); ts.WriteLine("ASSEMBLY_VERSION={0}", assemblyVersion); ts.WriteLine("AC_SUBST(ASSEMBLY_VERSION)"); ts.WriteLine("PUBKEY=`sn -t $PACKAGE_NAME.snk | grep 'Public Key Token' | awk -F: '{print $2}' | sed -e 's/^ //'`"); ts.WriteLine("AC_SUBST(PUBKEY)"); ts.WriteLine(); ts.WriteLine("AM_MAINTAINER_MODE"); ts.WriteLine(); ts.WriteLine("dnl AC_PROG_INTLTOOL([0.25])"); ts.WriteLine(); ts.WriteLine("AC_PROG_INSTALL"); ts.WriteLine(); ts.WriteLine("MONO_REQUIRED_VERSION=1.1"); ts.WriteLine(); ts.WriteLine("AC_MSG_CHECKING([whether we're compiling from CVS])"); ts.WriteLine("if test -f \"$srcdir/.cvs_version\" ; then"); ts.WriteLine(" from_cvs=yes"); ts.WriteLine("else"); ts.WriteLine(" if test -f \"$srcdir/.svn\" ; then"); ts.WriteLine(" from_cvs=yes"); ts.WriteLine(" else"); ts.WriteLine(" from_cvs=no"); ts.WriteLine(" fi"); ts.WriteLine("fi"); ts.WriteLine(); ts.WriteLine("AC_MSG_RESULT($from_cvs)"); ts.WriteLine(); ts.WriteLine("AC_PATH_PROG(MONO, mono)"); ts.WriteLine("AC_PATH_PROG(GMCS, gmcs)"); ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil)"); ts.WriteLine(); ts.WriteLine("AC_MSG_CHECKING([for mono])"); ts.WriteLine("dnl if test \"x$MONO\" = \"x\" ; then"); ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"mono\" in your PATH])"); ts.WriteLine("dnl else"); ts.WriteLine(" AC_MSG_RESULT([found])"); ts.WriteLine("dnl fi"); ts.WriteLine(); ts.WriteLine("AC_MSG_CHECKING([for gmcs])"); ts.WriteLine("dnl if test \"x$GMCS\" = \"x\" ; then"); ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"gmcs\" in your PATH])"); ts.WriteLine("dnl else"); ts.WriteLine(" AC_MSG_RESULT([found])"); ts.WriteLine("dnl fi"); ts.WriteLine(); //ts.WriteLine("AC_MSG_CHECKING([for gacutil])"); //ts.WriteLine("if test \"x$GACUTIL\" = \"x\" ; then"); //ts.WriteLine(" AC_MSG_ERROR([Can't find \"gacutil\" in your PATH])"); //ts.WriteLine("else"); //ts.WriteLine(" AC_MSG_RESULT([found])"); //ts.WriteLine("fi"); ts.WriteLine(); ts.WriteLine("AC_SUBST(PATH)"); ts.WriteLine("AC_SUBST(LD_LIBRARY_PATH)"); ts.WriteLine(); ts.WriteLine("dnl CSFLAGS=\"-debug -nowarn:1574\""); ts.WriteLine("CSFLAGS=\"\""); ts.WriteLine("AC_SUBST(CSFLAGS)"); ts.WriteLine(); // ts.WriteLine("AC_MSG_CHECKING(--disable-sdl argument)"); // ts.WriteLine("AC_ARG_ENABLE(sdl,"); // ts.WriteLine(" [ --disable-sdl Disable Sdl interface.],"); // ts.WriteLine(" [disable_sdl=$disableval],"); // ts.WriteLine(" [disable_sdl=\"no\"])"); // ts.WriteLine("AC_MSG_RESULT($disable_sdl)"); // ts.WriteLine("if test \"$disable_sdl\" = \"yes\"; then"); // ts.WriteLine(" AC_DEFINE(FEAT_SDL)"); // ts.WriteLine("fi"); ts.WriteLine(); ts.WriteLine("dnl Find pkg-config"); ts.WriteLine("AC_PATH_PROG(PKGCONFIG, pkg-config, no)"); ts.WriteLine("if test \"x$PKG_CONFIG\" = \"xno\"; then"); ts.WriteLine(" AC_MSG_ERROR([You need to install pkg-config])"); ts.WriteLine("fi"); ts.WriteLine(); ts.WriteLine("PKG_CHECK_MODULES(MONO_DEPENDENCY, mono >= $MONO_REQUIRED_VERSION, has_mono=true, has_mono=false)"); ts.WriteLine("BUILD_DIR=\"bin\""); ts.WriteLine("AC_SUBST(BUILD_DIR)"); ts.WriteLine("CONFIG=\"Release\""); ts.WriteLine("AC_SUBST(CONFIG)"); ts.WriteLine(); ts.WriteLine("if test \"x$has_mono\" = \"xtrue\"; then"); ts.WriteLine(" AC_PATH_PROG(RUNTIME, mono, no)"); ts.WriteLine(" AC_PATH_PROG(CSC, gmcs, no)"); ts.WriteLine(" if test `uname -s` = \"Darwin\"; then"); ts.WriteLine(" LIB_PREFIX="); ts.WriteLine(" LIB_SUFFIX=.dylib"); ts.WriteLine(" else"); ts.WriteLine(" LIB_PREFIX=.so"); ts.WriteLine(" LIB_SUFFIX="); ts.WriteLine(" fi"); ts.WriteLine("else"); ts.WriteLine(" AC_PATH_PROG(CSC, csc.exe, no)"); ts.WriteLine(" if test x$CSC = \"xno\"; then"); ts.WriteLine(" AC_MSG_ERROR([You need to install either mono or .Net])"); ts.WriteLine(" else"); ts.WriteLine(" RUNTIME="); ts.WriteLine(" LIB_PREFIX="); ts.WriteLine(" LIB_SUFFIX=.dylib"); ts.WriteLine(" fi"); ts.WriteLine("fi"); ts.WriteLine(); ts.WriteLine("AC_SUBST(LIB_PREFIX)"); ts.WriteLine("AC_SUBST(LIB_SUFFIX)"); ts.WriteLine(); ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_CFLAGS)"); ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_LIBS)"); ts.WriteLine(); ts.WriteLine("dnl Find monodoc"); ts.WriteLine("MONODOC_REQUIRED_VERSION=1.0"); ts.WriteLine("AC_SUBST(MONODOC_REQUIRED_VERSION)"); ts.WriteLine("PKG_CHECK_MODULES(MONODOC_DEPENDENCY, monodoc >= $MONODOC_REQUIRED_VERSION, enable_monodoc=yes, enable_monodoc=no)"); ts.WriteLine(); ts.WriteLine("if test \"x$enable_monodoc\" = \"xyes\"; then"); ts.WriteLine(" AC_PATH_PROG(MONODOC, monodoc, no)"); ts.WriteLine(" if test x$MONODOC = xno; then"); ts.WriteLine(" enable_monodoc=no"); ts.WriteLine(" fi"); ts.WriteLine("else"); ts.WriteLine(" MONODOC="); ts.WriteLine("fi"); ts.WriteLine(); ts.WriteLine("AC_SUBST(MONODOC)"); ts.WriteLine("AM_CONDITIONAL(ENABLE_MONODOC, test \"x$enable_monodoc\" = \"xyes\")"); ts.WriteLine(); ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil, no)"); ts.WriteLine("if test \"x$GACUTIL\" = \"xno\" ; then"); ts.WriteLine(" AC_MSG_ERROR([No gacutil tool found])"); ts.WriteLine("fi"); ts.WriteLine(); // foreach(ProjectNode project in solution.ProjectsTableOrder) // { // if (project.Type == ProjectType.Library) // { // } // } ts.WriteLine("GACUTIL_FLAGS='/package $(PACKAGE_NAME) /gacdir $(DESTDIR)$(prefix)'"); ts.WriteLine("AC_SUBST(GACUTIL_FLAGS)"); ts.WriteLine(); ts.WriteLine("winbuild=no"); ts.WriteLine("case \"$host\" in"); ts.WriteLine(" *-*-mingw*|*-*-cygwin*)"); ts.WriteLine(" winbuild=yes"); ts.WriteLine(" ;;"); ts.WriteLine("esac"); ts.WriteLine("AM_CONDITIONAL(WINBUILD, test x$winbuild = xyes)"); ts.WriteLine(); // ts.WriteLine("dnl Check for SDL"); // ts.WriteLine(); // ts.WriteLine("AC_PATH_PROG([SDL_CONFIG], [sdl-config])"); // ts.WriteLine("have_sdl=no"); // ts.WriteLine("if test -n \"${SDL_CONFIG}\"; then"); // ts.WriteLine(" have_sdl=yes"); // ts.WriteLine(" SDL_CFLAGS=`$SDL_CONFIG --cflags`"); // ts.WriteLine(" SDL_LIBS=`$SDL_CONFIG --libs`"); // ts.WriteLine(" #"); // ts.WriteLine(" # sdl-config sometimes emits an rpath flag pointing at its library"); // ts.WriteLine(" # installation directory. We don't want this, as it prevents users from"); // ts.WriteLine(" # linking sdl-viewer against, for example, a locally compiled libGL when a"); // ts.WriteLine(" # version of the library also exists in SDL's library installation"); // ts.WriteLine(" # directory, typically /usr/lib."); // ts.WriteLine(" #"); // ts.WriteLine(" SDL_LIBS=`echo $SDL_LIBS | sed 's/-Wl,-rpath,[[^ ]]* //'`"); // ts.WriteLine("fi"); // ts.WriteLine("AC_SUBST([SDL_CFLAGS])"); // ts.WriteLine("AC_SUBST([SDL_LIBS])"); ts.WriteLine(); ts.WriteLine("AC_OUTPUT(["); ts.WriteLine("Makefile"); // TODO: this does not work quite right. //ts.WriteLine("Properties/AssemblyInfo.cs"); foreach(ProjectNode project in solution.ProjectsTableOrder) { if (project.Type == ProjectType.Library) { ts.WriteLine(project.Name + ".pc"); } // string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); // ts.WriteLine(Helper.NormalizePath(Helper.MakeFilePath(path, "Include"),'/')); } ts.WriteLine("])"); ts.WriteLine(); ts.WriteLine("#po/Makefile.in"); ts.WriteLine(); ts.WriteLine("echo \"---\""); ts.WriteLine("echo \"Configuration summary\""); ts.WriteLine("echo \"\""); ts.WriteLine("echo \" * Installation prefix: $prefix\""); ts.WriteLine("echo \" * compiler: $CSC\""); ts.WriteLine("echo \" * Documentation: $enable_monodoc ($MONODOC)\""); ts.WriteLine("echo \" * Package Name: $PACKAGE_NAME\""); ts.WriteLine("echo \" * Version: $PACKAGE_VERSION\""); ts.WriteLine("echo \" * Public Key: $PUBKEY\""); ts.WriteLine("echo \"\""); ts.WriteLine("echo \"---\""); ts.WriteLine(); } ts.NewLine = "\n"; foreach (ProjectNode project in solution.ProjectsTableOrder) { if (project.GenerateAssemblyInfoFile) { GenerateAssemblyInfoFile(solution, combFile); } } }
private static void GenerateAssemblyInfoFile(SolutionNode solution, string combFile) { System.IO.Directory.CreateDirectory(Helper.MakePathRelativeTo(solution.FullPath, "Properties")); combFile = Helper.MakeFilePath(solution.FullPath + "/Properties/", "AssemblyInfo.cs", "in"); StreamWriter ai = new StreamWriter(combFile); using (ai) { ai.WriteLine("#region License"); ai.WriteLine("/*"); ai.WriteLine("MIT License"); ai.WriteLine("Copyright (c)2003-2006 Tao Framework Team"); ai.WriteLine("http://www.taoframework.com"); ai.WriteLine("All rights reserved."); ai.WriteLine(""); ai.WriteLine("Permission is hereby granted, free of charge, to any person obtaining a copy"); ai.WriteLine("of this software and associated documentation files (the \"Software\"), to deal"); ai.WriteLine("in the Software without restriction, including without limitation the rights"); ai.WriteLine("to use, copy, modify, merge, publish, distribute, sublicense, and/or sell"); ai.WriteLine("copies of the Software, and to permit persons to whom the Software is"); ai.WriteLine("furnished to do so, subject to the following conditions:"); ai.WriteLine(""); ai.WriteLine("The above copyright notice and this permission notice shall be included in all"); ai.WriteLine("copies or substantial portions of the Software."); ai.WriteLine(""); ai.WriteLine("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR"); ai.WriteLine("IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,"); ai.WriteLine("FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE"); ai.WriteLine("AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER"); ai.WriteLine("LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,"); ai.WriteLine("OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE"); ai.WriteLine("SOFTWARE."); ai.WriteLine("*/"); ai.WriteLine("#endregion License"); ai.WriteLine(""); ai.WriteLine("using System;"); ai.WriteLine("using System.Reflection;"); ai.WriteLine("using System.Runtime.InteropServices;"); ai.WriteLine("using System.Security;"); ai.WriteLine("using System.Security.Permissions;"); ai.WriteLine(""); ai.WriteLine("[assembly: AllowPartiallyTrustedCallers]"); ai.WriteLine("[assembly: AssemblyCompany(\"Tao Framework -- http://www.taoframework.com\")]"); ai.WriteLine("[assembly: AssemblyConfiguration(\"Retail\")]"); ai.WriteLine("[assembly: AssemblyCopyright(\"Copyright (c)2003-2006 Tao Framework Team. All rights reserved.\")]"); ai.WriteLine("[assembly: AssemblyCulture(\"\")]"); ai.WriteLine("[assembly: AssemblyDefaultAlias(\"@PACKAGE_NAME@\")]"); ai.WriteLine("[assembly: AssemblyDelaySign(false)]"); ai.WriteLine("[assembly: AssemblyDescription(\"@DESCRIPTION@\")]"); ai.WriteLine("[assembly: AssemblyFileVersion(\"@ASSEMBLY_VERSION@\")]"); ai.WriteLine("[assembly: AssemblyInformationalVersion(\"@ASSEMBLY_VERSION@\")]"); ai.WriteLine("[assembly: AssemblyKeyName(\"\")]"); ai.WriteLine("[assembly: AssemblyProduct(\"@[email protected]\")]"); ai.WriteLine("[assembly: AssemblyTitle(\"@DESCRIPTION@\")]"); ai.WriteLine("[assembly: AssemblyTrademark(\"Tao Framework -- http://www.taoframework.com\")]"); ai.WriteLine("[assembly: AssemblyVersion(\"@ASSEMBLY_VERSION@\")]"); ai.WriteLine("[assembly: CLSCompliant(true)]"); ai.WriteLine("[assembly: ComVisible(false)]"); ai.WriteLine("[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.Execution)]"); ai.WriteLine("[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.SkipVerification)]"); ai.WriteLine("[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.UnmanagedCode)]"); } //return combFile; }
private static string BuildReference(SolutionNode solution, ReferenceNode refr) { string ret = ""; if(solution.ProjectsTable.ContainsKey(refr.Name)) { ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; string fileRef = FindFileReference(refr.Name, project); string finalPath = Helper.NormalizePath(Helper.MakeFilePath(project.FullPath + "/$(BUILD_DIR)/$(CONFIG)/", refr.Name, "dll"), '/'); ret += finalPath; return ret; } else { ProjectNode project = (ProjectNode)refr.Parent; string fileRef = FindFileReference(refr.Name, project); if(refr.Path != null || fileRef != null) { string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path + "/" + refr.Name + ".dll", '/') : fileRef; ret += Path.Combine(project.Path, finalPath); return ret; } try { //Assembly assem = Assembly.Load(refr.Name); //if (assem != null) //{ // int index = refr.Name.IndexOf(","); // if ( index > 0) // { // ret += assem.Location; // //Console.WriteLine("Location1: " + assem.Location); // } // else // { // ret += (refr.Name + ".dll"); // //Console.WriteLine("Location2: " + assem.Location); // } //} //else //{ int index = refr.Name.IndexOf(","); if ( index > 0) { ret += refr.Name.Substring(0, index) + ".dll"; //Console.WriteLine("Location3: " + assem.Location); } else { ret += (refr.Name + ".dll"); //Console.WriteLine("Location4: " + assem.Location); } //} } catch (System.NullReferenceException e) { e.ToString(); int index = refr.Name.IndexOf(","); if ( index > 0) { ret += refr.Name.Substring(0, index) + ".dll"; //Console.WriteLine("Location5: " + assem.Location); } else { ret += (refr.Name + ".dll"); //Console.WriteLine("Location6: " + assem.Location); } } } return ret; }
private void WriteCombine(SolutionNode solution) { m_Kernel.Log.Write("Creating MonoDevelop combine and project files"); foreach(ProjectNode project in solution.Projects) { if(m_Kernel.AllowProject(project.FilterGroups)) { m_Kernel.Log.Write("...Creating project: {0}", project.Name); WriteProject(solution, project); } } m_Kernel.Log.Write(""); string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds"); StreamWriter ss = new StreamWriter(combFile); m_Kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); int count = 0; using(ss) { ss.WriteLine("<Combine name=\"{0}\" fileversion=\"2.0\" description=\"\">", solution.Name); count = 0; foreach(ConfigurationNode conf in solution.Configurations) { if(count == 0) { ss.WriteLine(" <Configurations active=\"{0}\">", conf.Name); } ss.WriteLine(" <Configuration name=\"{0}\" ctype=\"CombineConfiguration\">", conf.Name); foreach(ProjectNode project in solution.Projects) { ss.WriteLine(" <Entry configuration=\"{1}\" build=\"True\" name=\"{0}\" />", project.Name, conf.Name); } ss.WriteLine(" </Configuration>"); count++; } ss.WriteLine(" </Configurations>"); count = 0; foreach(ProjectNode project in solution.Projects) { if(count == 0) ss.WriteLine(" <StartMode startupentry=\"{0}\" single=\"True\">", project.Name); ss.WriteLine(" <Execute type=\"None\" entry=\"{0}\" />", project.Name); count++; } ss.WriteLine(" </StartMode>"); ss.WriteLine(" <Entries>"); foreach(ProjectNode project in solution.Projects) { string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); ss.WriteLine(" <Entry filename=\"{0}\" />", Helper.MakeFilePath(path, project.Name, "mdp")); } ss.WriteLine(" </Entries>"); ss.WriteLine("</Combine>"); } m_Kernel.CurrentWorkingDirectory.Pop(); }
private void WriteSolution(SolutionNode solution) { m_Kernel.Log.Write("Creating makefile for {0}", solution.Name); m_Kernel.CurrentWorkingDirectory.Push(); string file = "Makefile";// Helper.MakeFilePath(solution.FullPath, solution.Name, "make"); StreamWriter f = new StreamWriter(file); Helper.SetCurrentDir(Path.GetDirectoryName(file)); using (f) { WriteIntro(f, solution); WritePhony(f, solution); foreach (ProjectNode project in solution.Projects) { m_Kernel.Log.Write("...Creating Project: {0}", project.Name); WriteProject(f, solution, project); } } m_Kernel.Log.Write(""); m_Kernel.CurrentWorkingDirectory.Pop(); }
private static string BuildReference(SolutionNode solution, ReferenceNode refr) { string ret = ""; if (solution.ProjectsTable.ContainsKey(refr.Name)) { ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; string fileRef = FindFileReference(refr.Name, project); string finalPath = Helper.NormalizePath(Helper.MakeFilePath("${build.dir}/", refr.Name, GetExtension(refr.Name)), '/'); ret += finalPath; return ret; } else { ProjectNode project = (ProjectNode)refr.Parent; string fileRef = FindFileReference(refr.Name, project); string ext = GetExtension(refr.Name); if (refr.Path != null || fileRef != null) { string finalPath = (refr.Path != null) ? Helper.NormalizePath(Helper.MakeFilePath("${build.dir}/", refr.Name, ext), '/') : fileRef; ret += finalPath; return ret; } if (refr.Name.EndsWith(".exe") || refr.Name.EndsWith(".dll")) ret += refr.Name; else ret += refr.Name + ".dll"; } return ret; }
private void WriteProject(SolutionNode solution, ProjectNode project) { if (!tools.ContainsKey(project.Language)) { throw new UnknownLanguageException("Unknown .NET language: " + project.Language); } ToolInfo toolInfo = (ToolInfo)tools[project.Language]; string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); StreamWriter ps = new StreamWriter(projectFile); kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); #region Project File using (ps) { ps.WriteLine("<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); //ps.WriteLine(" <{0}", toolInfo.XMLTag); ps.WriteLine(" <PropertyGroup>"); ps.WriteLine(" <ProjectType>Local</ProjectType>"); ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", this.ProductVersion); ps.WriteLine(" <SchemaVersion>{0}</SchemaVersion>", this.SchemaVersion); ps.WriteLine(" <ProjectGuid>{{{0}}}</ProjectGuid>", project.Guid.ToString().ToUpper()); ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>"); ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>"); //ps.WriteLine(" <Build>"); //ps.WriteLine(" <Settings"); ps.WriteLine(" <ApplicationIcon>{0}</ApplicationIcon>", project.AppIcon); ps.WriteLine(" <AssemblyKeyContainerName>"); ps.WriteLine(" </AssemblyKeyContainerName>"); ps.WriteLine(" <AssemblyName>{0}</AssemblyName>", project.AssemblyName); foreach (ConfigurationNode conf in project.Configurations) { if (conf.Options.KeyFile != "") { ps.WriteLine(" <AssemblyOriginatorKeyFile>{0}</AssemblyOriginatorKeyFile>", conf.Options.KeyFile); ps.WriteLine(" <SignAssembly>true</SignAssembly>"); break; } } ps.WriteLine(" <DefaultClientScript>JScript</DefaultClientScript>"); ps.WriteLine(" <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>"); ps.WriteLine(" <DefaultTargetSchema>IE50</DefaultTargetSchema>"); ps.WriteLine(" <DelaySign>false</DelaySign>"); //if(m_Version == VSVersion.VS70) // ps.WriteLine(" NoStandardLibraries = \"false\""); ps.WriteLine(" <OutputType>{0}</OutputType>", project.Type.ToString()); ps.WriteLine(" <AppDesignerFolder>{0}</AppDesignerFolder>", project.DesignerFolder); ps.WriteLine(" <RootNamespace>{0}</RootNamespace>", project.RootNamespace); ps.WriteLine(" <StartupObject>{0}</StartupObject>", project.StartupObject); //ps.WriteLine(" >"); ps.WriteLine(" <FileUpgradeFlags>"); ps.WriteLine(" </FileUpgradeFlags>"); ps.WriteLine(" </PropertyGroup>"); foreach (ConfigurationNode conf in project.Configurations) { ps.Write(" <PropertyGroup "); ps.WriteLine("Condition=\" '$(Configuration)|$(Platform)' == '{0}|AnyCPU' \">", conf.Name); ps.WriteLine(" <AllowUnsafeBlocks>{0}</AllowUnsafeBlocks>", conf.Options["AllowUnsafe"]); ps.WriteLine(" <BaseAddress>{0}</BaseAddress>", conf.Options["BaseAddress"]); ps.WriteLine(" <CheckForOverflowUnderflow>{0}</CheckForOverflowUnderflow>", conf.Options["CheckUnderflowOverflow"]); ps.WriteLine(" <ConfigurationOverrideFile>"); ps.WriteLine(" </ConfigurationOverrideFile>"); ps.WriteLine(" <DefineConstants>{0}</DefineConstants>", conf.Options["CompilerDefines"]); ps.WriteLine(" <DocumentationFile>{0}</DocumentationFile>", conf.Options["XmlDocFile"]); ps.WriteLine(" <DebugSymbols>{0}</DebugSymbols>", conf.Options["DebugInformation"]); ps.WriteLine(" <FileAlignment>{0}</FileAlignment>", conf.Options["FileAlignment"]); // ps.WriteLine(" <IncrementalBuild = \"{0}\"", conf.Options["IncrementalBuild"]); // if(m_Version == VSVersion.VS71) // { // ps.WriteLine(" NoStdLib = \"{0}\"", conf.Options["NoStdLib"]); // ps.WriteLine(" NoWarn = \"{0}\"", conf.Options["SuppressWarnings"]); // } ps.WriteLine(" <Optimize>{0}</Optimize>", conf.Options["OptimizeCode"]); ps.WriteLine(" <OutputPath>{0}</OutputPath>", Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); ps.WriteLine(" <RegisterForComInterop>{0}</RegisterForComInterop>", conf.Options["RegisterComInterop"]); ps.WriteLine(" <RemoveIntegerChecks>{0}</RemoveIntegerChecks>", conf.Options["RemoveIntegerChecks"]); ps.WriteLine(" <TreatWarningsAsErrors>{0}</TreatWarningsAsErrors>", conf.Options["WarningsAsErrors"]); ps.WriteLine(" <WarningLevel>{0}</WarningLevel>", conf.Options["WarningLevel"]); ps.WriteLine(" <NoWarn>{0}</NoWarn>", conf.Options["SuppressWarnings"]); ps.WriteLine(" </PropertyGroup>"); } //ps.WriteLine(" </Settings>"); // Assembly References ps.WriteLine(" <ItemGroup>"); string refPath = ((ReferencePathNode) project.ReferencePaths[0]).Path; foreach (ReferenceNode refr in project.References) { if (!solution.ProjectsTable.ContainsKey(refr.Name)) { ps.Write(" <Reference"); ps.Write(" Include=\""); ps.Write(refr.Name); ps.WriteLine("\" >"); string path; if( refr.Name.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase )) { path = Helper.NormalizePath(Path.Combine( refPath, refr.Name), '\\'); } else { path = refr.Name + ".dll"; } // TODO: Allow reference to *.exe files ps.WriteLine(" <HintPath>{0}</HintPath>", path ); ps.WriteLine(" <Private>{0}</Private>", refr.LocalCopy); ps.WriteLine(" </Reference>"); } } ps.WriteLine(" </ItemGroup>"); //Project References ps.WriteLine(" <ItemGroup>"); foreach (ReferenceNode refr in project.References) { if (solution.ProjectsTable.ContainsKey(refr.Name)) { ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; // TODO: Allow reference to visual basic projects string path = Helper.MakePathRelativeTo(project.FullPath, Helper.MakeFilePath(refProject.FullPath, refProject.Name, "csproj")); ps.WriteLine(" <ProjectReference Include=\"{0}\">", path ); //<ProjectReference Include="..\..\RealmForge\Utility\RealmForge.Utility.csproj"> ps.WriteLine(" <Name>{0}</Name>", refProject.Name); // <Name>RealmForge.Utility</Name> ps.WriteLine(" <Project>{{{0}}}</Project>", refProject.Guid.ToString().ToUpper()); // <Project>{6880D1D3-69EE-461B-B841-5319845B20D3}</Project> ps.WriteLine(" <Package>{0}</Package>", toolInfo.Guid.ToString().ToUpper()); // <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> ps.WriteLine("\t\t\t<Private>{0}</Private>", refr.LocalCopy); ps.WriteLine(" </ProjectReference>"); //</ProjectReference> } else { } } ps.WriteLine(" </ItemGroup>"); // ps.WriteLine(" </Build>"); ps.WriteLine(" <ItemGroup>"); // ps.WriteLine(" <Include>"); ArrayList list = new ArrayList(); foreach (string file in project.Files) { // if (file == "Properties\\Bind.Designer.cs") // { // Console.WriteLine("Wait a minute!"); // Console.WriteLine(project.Files.GetSubType(file).ToString()); // } if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings && project.Files.GetSubType(file) != SubType.Designer) { ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); int slash = file.LastIndexOf('\\'); if (slash == -1) { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", file); } else { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", file.Substring(slash + 1, file.Length - slash - 1)); } ps.WriteLine(" <SubType>Designer</SubType>"); ps.WriteLine(" </EmbeddedResource>"); // } if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) == SubType.Designer) { ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); ps.WriteLine(" <SubType>" + project.Files.GetSubType(file) + "</SubType>"); ps.WriteLine(" <Generator>ResXFileCodeGenerator</Generator>"); ps.WriteLine(" <LastGenOutput>Resources.Designer.cs</LastGenOutput>"); ps.WriteLine(" </EmbeddedResource>"); ps.WriteLine(" <Compile Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"); ps.WriteLine(" <AutoGen>True</AutoGen>"); ps.WriteLine(" <DesignTime>True</DesignTime>"); ps.WriteLine(" <DependentUpon>Resources.resx</DependentUpon>"); ps.WriteLine(" </Compile>"); list.Add(file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"); } if (project.Files.GetSubType(file).ToString() == "Settings") { //Console.WriteLine("File: " + file); //Console.WriteLine("Last index: " + file.LastIndexOf('.')); //Console.WriteLine("Length: " + file.Length); ps.Write(" <{0} ", project.Files.GetBuildAction(file)); ps.WriteLine("Include=\"{0}\">", file); int slash = file.LastIndexOf('\\'); string fileName = file.Substring(slash + 1, file.Length - slash - 1); if (project.Files.GetBuildAction(file) == BuildAction.None) { ps.WriteLine(" <Generator>SettingsSingleFileGenerator</Generator>"); //Console.WriteLine("FileName: " + fileName); //Console.WriteLine("FileNameMain: " + fileName.Substring(0, fileName.LastIndexOf('.'))); //Console.WriteLine("FileNameExt: " + fileName.Substring(fileName.LastIndexOf('.'), fileName.Length - fileName.LastIndexOf('.'))); if (slash == -1) { ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); } else { ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); } } else { ps.WriteLine(" <SubType>Code</SubType>"); ps.WriteLine(" <AutoGen>True</AutoGen>"); ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>"); string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.')); string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.')); ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", fileNameShorter + ".settings"); } ps.WriteLine(" </{0}>", project.Files.GetBuildAction(file)); } else if (project.Files.GetSubType(file) != SubType.Designer) { if (!list.Contains(file)) { ps.Write(" <{0} ", project.Files.GetBuildAction(file)); ps.WriteLine("Include=\"{0}\">", file); if (file.Contains("Designer.cs")) { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", file.Substring(0, file.IndexOf(".Designer.cs")) + ".cs"); } if (project.Files.GetIsLink(file)) { ps.WriteLine(" <Link>{0}</Link>", Path.GetFileName(file)); } else if (project.Files.GetBuildAction(file) != BuildAction.None) { if (project.Files.GetBuildAction(file) != BuildAction.EmbeddedResource) { ps.WriteLine(" <SubType>{0}</SubType>", project.Files.GetSubType(file)); } } if (project.Files.GetCopyToOutput(file) != CopyToOutput.Never) { ps.WriteLine(" <CopyToOutputDirectory>{0}</CopyToOutputDirectory>", project.Files.GetCopyToOutput(file)); } ps.WriteLine(" </{0}>", project.Files.GetBuildAction(file)); } } } // ps.WriteLine(" </Include>"); ps.WriteLine(" </ItemGroup>"); ps.WriteLine(" <Import Project=\"" + toolInfo.ImportProject + "\" />"); ps.WriteLine(" <PropertyGroup>"); ps.WriteLine(" <PreBuildEvent>"); ps.WriteLine(" </PreBuildEvent>"); ps.WriteLine(" <PostBuildEvent>"); ps.WriteLine(" </PostBuildEvent>"); ps.WriteLine(" </PropertyGroup>"); // ps.WriteLine(" </{0}>", toolInfo.XMLTag); ps.WriteLine("</Project>"); } #endregion #region User File ps = new StreamWriter(projectFile + ".user"); using (ps) { ps.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); //ps.WriteLine( "<VisualStudioProject>" ); //ps.WriteLine(" <{0}>", toolInfo.XMLTag); //ps.WriteLine(" <Build>"); ps.WriteLine(" <PropertyGroup>"); //ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project)); ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>"); ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>"); if (projectFile.Contains( "OpenSim.csproj" )) { ps.WriteLine(" <StartArguments>-loginserver -sandbox -accounts</StartArguments>"); } ps.WriteLine(" <ReferencePath>{0}</ReferencePath>", MakeRefPath(project)); ps.WriteLine(" <LastOpenVersion>{0}</LastOpenVersion>", this.ProductVersion); ps.WriteLine(" <ProjectView>ProjectFiles</ProjectView>"); ps.WriteLine(" <ProjectTrust>0</ProjectTrust>"); ps.WriteLine(" </PropertyGroup>"); foreach (ConfigurationNode conf in project.Configurations) { ps.Write(" <PropertyGroup"); ps.Write(" Condition = \" '$(Configuration)|$(Platform)' == '{0}|AnyCPU' \"", conf.Name); ps.WriteLine(" />"); } ps.WriteLine("</Project>"); } #endregion kernel.CurrentWorkingDirectory.Pop(); }
private void WriteCombine(SolutionNode solution) { m_Kernel.Log.Write("Creating NAnt build files"); foreach (ProjectNode project in solution.Projects) { if (m_Kernel.AllowProject(project.FilterGroups)) { m_Kernel.Log.Write("...Creating project: {0}", project.Name); WriteProject(solution, project); } } m_Kernel.Log.Write(""); string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); StreamWriter ss = new StreamWriter(combFile); m_Kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); using (ss) { ss.WriteLine("<?xml version=\"1.0\" ?>"); ss.WriteLine("<project name=\"{0}\" default=\"build\">", solution.Name); ss.WriteLine(" <echo message=\"Using '${nant.settings.currentframework}' Framework\"/>"); ss.WriteLine(); //ss.WriteLine(" <property name=\"dist.dir\" value=\"dist\" />"); //ss.WriteLine(" <property name=\"source.dir\" value=\"source\" />"); ss.WriteLine(" <property name=\"bin.dir\" value=\"bin\" />"); ss.WriteLine(" <property name=\"obj.dir\" value=\"obj\" />"); ss.WriteLine(" <property name=\"doc.dir\" value=\"doc\" />"); ss.WriteLine(" <property name=\"project.main.dir\" value=\"${project::get-base-directory()}\" />"); foreach (ConfigurationNode conf in solution.Configurations) { // Set the project.config to a non-debug configuration if (conf.Options["DebugInformation"].ToString().ToLower() != "true") { ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name); } ss.WriteLine(); ss.WriteLine(" <target name=\"{0}\" description=\"\">", conf.Name); ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name); ss.WriteLine(" <property name=\"build.debug\" value=\"{0}\" />", conf.Options["DebugInformation"].ToString().ToLower()); ss.WriteLine(" </target>"); ss.WriteLine(); } ss.WriteLine(" <target name=\"net-1.1\" description=\"Sets framework to .NET 1.1\">"); ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-1.1\" />"); ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine(" <target name=\"net-2.0\" description=\"Sets framework to .NET 2.0\">"); ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-2.0\" />"); ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine(" <target name=\"net-3.5\" description=\"Sets framework to .NET 3.5\">"); ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-3.5\" />"); ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine(" <target name=\"mono-1.0\" description=\"Sets framework to mono 1.0\">"); ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-1.0\" />"); ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine(" <target name=\"mono-2.0\" description=\"Sets framework to mono 2.0\">"); ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-2.0\" />"); ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine(" <target name=\"mono-3.5\" description=\"Sets framework to mono 3.5\">"); ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-3.5\" />"); ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine(" <target name=\"init\" description=\"\">"); ss.WriteLine(" <call target=\"${project.config}\" />"); ss.WriteLine(" <property name=\"sys.os.platform\""); ss.WriteLine(" value=\"${platform::get-name()}\""); ss.WriteLine(" />"); ss.WriteLine(" <echo message=\"Platform ${sys.os.platform}\" />"); ss.WriteLine(" <property name=\"build.dir\" value=\"${project::get-base-directory()}/${bin.dir}\" />"); ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine(" <target name=\"clean\" description=\"\">"); ss.WriteLine(" <echo message=\"Deleting all builds from all configurations\" />"); //ss.WriteLine(" <delete dir=\"${dist.dir}\" failonerror=\"false\" />"); ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />"); ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />"); foreach (ProjectNode project in solution.Projects) { string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); ss.Write(" <nant buildfile=\"{0}\"", Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"), '/')); ss.WriteLine(" target=\"clean\" />"); } ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine(" <target name=\"build\" depends=\"init\" description=\"\">"); foreach (ProjectNode project in solution.ProjectsTableOrder) { string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); ss.Write(" <nant buildfile=\"{0}\"", Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"), '/')); ss.WriteLine(" target=\"build\" />"); } ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine(" <target name=\"build-release\" depends=\"Release, init, build\" description=\"Builds in Release mode\" />"); ss.WriteLine(); ss.WriteLine(" <target name=\"build-debug\" depends=\"Debug, init, build\" description=\"Builds in Debug mode\" />"); ss.WriteLine(); //ss.WriteLine(" <target name=\"package\" depends=\"clean, doc, copyfiles, zip\" description=\"Builds in Release mode\" />"); ss.WriteLine(" <target name=\"package\" depends=\"clean, doc\" description=\"Builds all\" />"); ss.WriteLine(); ss.WriteLine(" <target name=\"doc\" depends=\"build-release\">"); ss.WriteLine(" <echo message=\"Generating all documentation from all builds\" />"); foreach (ProjectNode project in solution.Projects) { string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); ss.Write(" <nant buildfile=\"{0}\"", Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"), '/')); ss.WriteLine(" target=\"doc\" />"); } ss.WriteLine(" </target>"); ss.WriteLine(); ss.WriteLine("</project>"); } m_Kernel.CurrentWorkingDirectory.Pop(); }
public void ProcessFile(ProcessNode node, SolutionNode parent) { if (node.IsValid) { ArrayList list = new ArrayList(); ProcessFile(node.Path, list); foreach (SolutionNode solution in list) parent.SolutionsTable[solution.Name] = solution; } }
private void WritePhony(StreamWriter f, SolutionNode solution) { string defconf = ""; foreach (ConfigurationNode conf in solution.Configurations) { defconf = conf.Name; break; } f.Write(".PHONY: all"); foreach (ProjectNode proj in solution.Projects) f.Write(" {0} {0}-clean", proj.Name); foreach (ConfigurationNode conf in solution.Configurations) f.Write(" {0} {0}-clean", conf.Name); foreach (ProjectNode proj in solution.Projects) foreach (ConfigurationNode conf in solution.Configurations) f.Write(" {0}-{1} {0}-{1}-clean", proj.Name, conf.Name); f.WriteLine(); f.WriteLine(); f.WriteLine("all: {0}", defconf); f.WriteLine(); f.Write("clean:"); foreach (ConfigurationNode conf in solution.Configurations) f.Write(" {0}-clean", conf.Name); f.WriteLine(); f.WriteLine(); foreach (ConfigurationNode conf in solution.Configurations) { f.Write("{0}: ", conf.Name); foreach (ProjectNode proj in solution.Projects) f.Write(" {0}-{1}", proj.Name, conf.Name); f.WriteLine(); f.WriteLine(); f.Write("{0}-clean: ", conf.Name); foreach (ProjectNode proj in solution.Projects) f.Write(" {0}-{1}-clean", proj.Name, conf.Name); f.WriteLine(); f.WriteLine(); } foreach (ProjectNode proj in solution.Projects) { f.WriteLine("{0}: {0}-{1}", proj.Name, defconf); f.WriteLine(); f.Write("{0}-clean:", proj.Name); foreach (ConfigurationNode conf in proj.Configurations) f.Write(" {0}-{1}-clean", proj.Name, conf.Name); f.WriteLine(); f.WriteLine(); } }
private void CleanSolution(SolutionNode solution) { m_Kernel.Log.Write("Cleaning NAnt build files for", solution.Name); string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); Helper.DeleteIfExists(slnFile); foreach (ProjectNode project in solution.Projects) { CleanProject(project); } m_Kernel.Log.Write(""); }
private void WriteProject(SolutionNode solution, ProjectNode project) { if(!m_Tools.ContainsKey(project.Language)) { throw new UnknownLanguageException("Unknown .NET language: " + project.Language); } ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language]; string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); StreamWriter ps = new StreamWriter(projectFile); m_Kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); IEnumerator enumerator; //ConfigurationNode scripts; using(ps) { ps.WriteLine("<VisualStudioProject>"); ps.WriteLine(" <{0}", toolInfo.XmlTag); ps.WriteLine("\t\t\t\tProjectType = \"Local\""); ps.WriteLine("\t\t\t\tProductVersion = \"{0}\"", this.ProductVersion); ps.WriteLine("\t\t\t\tSchemaVersion = \"{0}\"", this.SchemaVersion); ps.WriteLine("\t\t\t\tProjectGuid = \"{{{0}}}\"", project.Guid.ToString().ToUpper()); ps.WriteLine("\t\t>"); ps.WriteLine("\t\t\t\t<Build>"); ps.WriteLine(" <Settings"); ps.WriteLine("\t\t\t\t ApplicationIcon = \"{0}\"",project.AppIcon); ps.WriteLine("\t\t\t\t AssemblyKeyContainerName = \"\""); ps.WriteLine("\t\t\t\t AssemblyName = \"{0}\"", project.AssemblyName); ps.WriteLine("\t\t\t\t AssemblyOriginatorKeyFile = \"\""); ps.WriteLine("\t\t\t\t DefaultClientScript = \"JScript\""); ps.WriteLine("\t\t\t\t DefaultHTMLPageLayout = \"Grid\""); ps.WriteLine("\t\t\t\t DefaultTargetSchema = \"IE50\""); ps.WriteLine("\t\t\t\t DelaySign = \"false\""); if(this.Version == VSVersion.VS70) { ps.WriteLine("\t\t\t\t NoStandardLibraries = \"false\""); } ps.WriteLine("\t\t\t\t OutputType = \"{0}\"", project.Type.ToString()); enumerator = project.Configurations.GetEnumerator(); enumerator.Reset(); enumerator.MoveNext(); foreach(ConfigurationNode conf in project.Configurations) { if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0) { ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString())); } else { ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"", conf.Options["PreBuildEvent"]); } if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0) { ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString())); } else { ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"", conf.Options["PostBuildEvent"]); } if (conf.Options["RunPostBuildEvent"] == null) { ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", "OnBuildSuccess"); } else { ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", conf.Options["RunPostBuildEvent"]); } break; } ps.WriteLine("\t\t\t\t RootNamespace = \"{0}\"", project.RootNamespace); ps.WriteLine("\t\t\t\t StartupObject = \"{0}\"", project.StartupObject); ps.WriteLine("\t\t >"); foreach(ConfigurationNode conf in project.Configurations) { ps.WriteLine("\t\t\t\t <Config"); ps.WriteLine("\t\t\t\t Name = \"{0}\"", conf.Name); ps.WriteLine("\t\t\t\t AllowUnsafeBlocks = \"{0}\"", conf.Options["AllowUnsafe"].ToString().ToLower()); ps.WriteLine("\t\t\t\t BaseAddress = \"{0}\"", conf.Options["BaseAddress"]); ps.WriteLine("\t\t\t\t CheckForOverflowUnderflow = \"{0}\"", conf.Options["CheckUnderflowOverflow"].ToString().ToLower()); ps.WriteLine("\t\t\t\t ConfigurationOverrideFile = \"\""); ps.WriteLine("\t\t\t\t DefineConstants = \"{0}\"", conf.Options["CompilerDefines"]); ps.WriteLine("\t\t\t\t DocumentationFile = \"{0}\"", GetXmlDocFile(project, conf));//default to the assembly name ps.WriteLine("\t\t\t\t DebugSymbols = \"{0}\"", conf.Options["DebugInformation"].ToString().ToLower()); ps.WriteLine("\t\t\t\t FileAlignment = \"{0}\"", conf.Options["FileAlignment"]); ps.WriteLine("\t\t\t\t IncrementalBuild = \"{0}\"", conf.Options["IncrementalBuild"].ToString().ToLower()); if(this.Version == VSVersion.VS71) { ps.WriteLine("\t\t\t\t NoStdLib = \"{0}\"", conf.Options["NoStdLib"].ToString().ToLower()); ps.WriteLine("\t\t\t\t NoWarn = \"{0}\"", conf.Options["SuppressWarnings"].ToString().ToLower()); } ps.WriteLine("\t\t\t\t Optimize = \"{0}\"", conf.Options["OptimizeCode"].ToString().ToLower()); ps.WriteLine(" OutputPath = \"{0}\"", Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); ps.WriteLine(" RegisterForComInterop = \"{0}\"", conf.Options["RegisterComInterop"].ToString().ToLower()); ps.WriteLine(" RemoveIntegerChecks = \"{0}\"", conf.Options["RemoveIntegerChecks"].ToString().ToLower()); ps.WriteLine(" TreatWarningsAsErrors = \"{0}\"", conf.Options["WarningsAsErrors"].ToString().ToLower()); ps.WriteLine(" WarningLevel = \"{0}\"", conf.Options["WarningLevel"]); ps.WriteLine(" />"); } ps.WriteLine(" </Settings>"); ps.WriteLine(" <References>"); foreach(ReferenceNode refr in project.References) { ps.WriteLine(" <Reference"); ps.WriteLine(" Name = \"{0}\"", refr.Name); ps.WriteLine(" AssemblyName = \"{0}\"", refr.Name); if(solution.ProjectsTable.ContainsKey(refr.Name)) { ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; ps.WriteLine(" Project = \"{{{0}}}\"", refProject.Guid.ToString().ToUpper()); ps.WriteLine(" Package = \"{0}\"", toolInfo.Guid.ToString().ToUpper()); } else { if(refr.Path != null) { ps.WriteLine(" HintPath = \"{0}\"", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); } } if(refr.LocalCopySpecified) { ps.WriteLine(" Private = \"{0}\"",refr.LocalCopy); } ps.WriteLine(" />"); } ps.WriteLine(" </References>"); ps.WriteLine(" </Build>"); ps.WriteLine(" <Files>"); ps.WriteLine(" <Include>"); foreach(string file in project.Files) { string fileName = file.Replace(".\\", ""); ps.WriteLine(" <File"); ps.WriteLine(" RelPath = \"{0}\"", fileName); ps.WriteLine(" SubType = \"{0}\"", project.Files.GetSubType(file)); ps.WriteLine(" BuildAction = \"{0}\"", project.Files.GetBuildAction(file)); ps.WriteLine(" />"); if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) { ps.WriteLine(" <File"); ps.WriteLine(" RelPath = \"{0}\"", fileName.Substring(0, fileName.LastIndexOf('.')) + ".resx"); int slash = fileName.LastIndexOf('\\'); if (slash == -1) { ps.WriteLine(" DependentUpon = \"{0}\"", fileName); } else { ps.WriteLine(" DependentUpon = \"{0}\"", fileName.Substring(slash + 1, fileName.Length - slash - 1)); } ps.WriteLine(" BuildAction = \"{0}\"", "EmbeddedResource"); ps.WriteLine(" />"); } } ps.WriteLine(" </Include>"); ps.WriteLine(" </Files>"); ps.WriteLine(" </{0}>", toolInfo.XmlTag); ps.WriteLine("</VisualStudioProject>"); } ps = new StreamWriter(projectFile + ".user"); using(ps) { ps.WriteLine("<VisualStudioProject>"); ps.WriteLine(" <{0}>", toolInfo.XmlTag); ps.WriteLine(" <Build>"); ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project)); foreach(ConfigurationNode conf in project.Configurations) { ps.WriteLine(" <Config"); ps.WriteLine(" Name = \"{0}\"", conf.Name); ps.WriteLine(" />"); } ps.WriteLine(" </Settings>"); ps.WriteLine(" </Build>"); ps.WriteLine(" </{0}>", toolInfo.XmlTag); ps.WriteLine("</VisualStudioProject>"); } m_Kernel.CurrentWorkingDirectory.Pop(); }
private void WriteProject(SolutionNode solution, ProjectNode project) { string projFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"); StreamWriter ss = new StreamWriter(projFile); m_Kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); bool hasDoc = false; using (ss) { ss.WriteLine("<?xml version=\"1.0\" ?>"); ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name); ss.WriteLine(" <target name=\"{0}\">", "build"); //ss.WriteLine(" <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />"); //ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />"); ss.WriteLine(" <echo message=\"Build Directory is ${build.dir}\" />"); ss.WriteLine(" <mkdir dir=\"${build.dir}\" />"); ss.Write(" <csc"); ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower()); ss.Write(" debug=\"{0}\"", "${build.debug}"); foreach (ConfigurationNode conf in project.Configurations) { if (conf.Options.KeyFile != "") { ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile); break; } } foreach (ConfigurationNode conf in project.Configurations) { ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe); break; } foreach (ConfigurationNode conf in project.Configurations) { ss.Write(" warnaserror=\"{0}\"", conf.Options.WarningsAsErrors); break; } foreach (ConfigurationNode conf in project.Configurations) { ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines); break; } foreach (ConfigurationNode conf in project.Configurations) { ss.Write(" nostdlib=\"{0}\"", conf.Options["NoStdLib"]); break; } ss.Write(" main=\"{0}\"", project.StartupObject); foreach (ConfigurationNode conf in project.Configurations) { if (GetXmlDocFile(project, conf) != "") { //ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf)); ss.Write(" doc=\"{0}\"", "${build.dir}/" + GetXmlDocFile(project, conf)); hasDoc = true; } break; } //ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}"); ss.Write(" output=\"{0}", "${build.dir}/${project::get-name()}"); if (project.Type == ProjectType.Library) { ss.Write(".dll\""); } else { ss.Write(".exe\""); } if (project.AppIcon != null && project.AppIcon.Length != 0) { ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon, '/')); } ss.WriteLine(">"); ss.WriteLine(" <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace); foreach (string file in project.Files) { switch (project.Files.GetBuildAction(file)) { case BuildAction.EmbeddedResource: ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />"); break; default: if (file.EndsWith(".resx") || (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)) { ss.WriteLine(" <include name=\"{0}\" />", file.Substring(0, file.LastIndexOf('.')) + ".resx"); } break; } } //if (project.Files.GetSubType(file).ToString() != "Code") //{ // ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); ss.WriteLine(" </resources>"); ss.WriteLine(" <sources failonempty=\"true\">"); foreach (string file in project.Files) { switch (project.Files.GetBuildAction(file)) { case BuildAction.Compile: if (!file.EndsWith(".resx")) ss.WriteLine(" <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />"); break; default: break; } } ss.WriteLine(" </sources>"); ss.WriteLine(" <references basedir=\"${project::get-base-directory()}\">"); ss.WriteLine(" <lib>"); ss.WriteLine(" <include name=\"${project::get-base-directory()}\" />"); //ss.WriteLine(" <include name=\"${project::get-base-directory()}/${build.dir}\" />"); ss.WriteLine(" <include name=\"${build.dir}\" />"); ss.WriteLine(" </lib>"); foreach (ReferenceNode refr in project.References) { ss.WriteLine(" <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, refr)) + "\" />", '/')); } ss.WriteLine(" </references>"); ArrayList suppressWarningsArray = new ArrayList(); ss.WriteLine(" <nowarn>"); foreach (ConfigurationNode conf in project.Configurations) { foreach (string s in conf.Options.SuppressWarnings.Split(new char[] { ',', ' ' })) { // duplicate check if (!String.IsNullOrEmpty(s) && !suppressWarningsArray.Contains(s)) { suppressWarningsArray.Add(s); ss.WriteLine(" <warning number=\"{0}\" />", s); } } } suppressWarningsArray.Clear(); ss.WriteLine(" </nowarn>"); ss.WriteLine(" </csc>"); ss.WriteLine(" </target>"); ss.WriteLine(" <target name=\"clean\">"); ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />"); ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />"); ss.WriteLine(" </target>"); ss.WriteLine(" <target name=\"doc\" description=\"Creates documentation.\">"); if (hasDoc) { ss.WriteLine(" <property name=\"doc.target\" value=\"\" />"); ss.WriteLine(" <if test=\"${platform::is-unix()}\">"); ss.WriteLine(" <property name=\"doc.target\" value=\"Web\" />"); ss.WriteLine(" </if>"); ss.WriteLine(" <ndoc failonerror=\"false\" verbose=\"true\">"); ss.WriteLine(" <assemblies basedir=\"${project::get-base-directory()}\">"); ss.Write(" <include name=\"${build.dir}/${project::get-name()}"); if (project.Type == ProjectType.Library) { ss.WriteLine(".dll\" />"); } else { ss.WriteLine(".exe\" />"); } ss.WriteLine(" </assemblies>"); ss.WriteLine(" <summaries basedir=\"${project::get-base-directory()}\">"); ss.WriteLine(" <include name=\"${build.dir}/${project::get-name()}.xml\"/>"); ss.WriteLine(" </summaries>"); ss.WriteLine(" <referencepaths basedir=\"${project::get-base-directory()}\">"); ss.WriteLine(" <include name=\"${build.dir}\" />"); // foreach(ReferenceNode refr in project.References) // { // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/'); // if (path != "") // { // ss.WriteLine(" <include name=\"{0}\" />", path); // } // } ss.WriteLine(" </referencepaths>"); ss.WriteLine(" <documenters>"); ss.WriteLine(" <documenter name=\"MSDN\">"); ss.WriteLine(" <property name=\"OutputDirectory\" value=\"${build.dir}/doc/${project::get-name()}\" />"); ss.WriteLine(" <property name=\"OutputTarget\" value=\"${doc.target}\" />"); ss.WriteLine(" <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />"); ss.WriteLine(" <property name=\"IncludeFavorites\" value=\"False\" />"); ss.WriteLine(" <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />"); ss.WriteLine(" <property name=\"SplitTOCs\" value=\"False\" />"); ss.WriteLine(" <property name=\"DefaulTOC\" value=\"\" />"); ss.WriteLine(" <property name=\"ShowVisualBasic\" value=\"True\" />"); ss.WriteLine(" <property name=\"AutoDocumentConstructors\" value=\"True\" />"); ss.WriteLine(" <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />"); ss.WriteLine(" <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />"); ss.WriteLine(" <property name=\"ShowMissingParams\" value=\"${build.debug}\" />"); ss.WriteLine(" <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />"); ss.WriteLine(" <property name=\"ShowMissingValues\" value=\"${build.debug}\" />"); ss.WriteLine(" <property name=\"DocumentInternals\" value=\"False\" />"); ss.WriteLine(" <property name=\"DocumentPrivates\" value=\"False\" />"); ss.WriteLine(" <property name=\"DocumentProtected\" value=\"True\" />"); ss.WriteLine(" <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />"); ss.WriteLine(" <property name=\"IncludeAssemblyVersion\" value=\"True\" />"); ss.WriteLine(" </documenter>"); ss.WriteLine(" </documenters>"); ss.WriteLine(" </ndoc>"); } ss.WriteLine(" </target>"); ss.WriteLine("</project>"); } m_Kernel.CurrentWorkingDirectory.Pop(); }
private void WriteSolution(SolutionNode solution) { m_Kernel.Log.Write("Creating Visual Studio {0} solution and project files", this.VersionName); foreach(ProjectNode project in solution.Projects) { if(m_Kernel.AllowProject(project.FilterGroups)) { m_Kernel.Log.Write("...Creating project: {0}", project.Name); WriteProject(solution, project); } } m_Kernel.Log.Write(""); string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); StreamWriter ss = new StreamWriter(solutionFile); m_Kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); using(ss) { ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion); foreach(ProjectNode project in solution.Projects) { if(!m_Tools.ContainsKey(project.Language)) { throw new UnknownLanguageException("Unknown .NET language: " + project.Language); } ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language]; string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"", toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name, toolInfo.FileExtension), project.Guid.ToString().ToUpper()); ss.WriteLine("\tProjectSection(ProjectDependencies) = postProject"); ss.WriteLine("\tEndProjectSection"); ss.WriteLine("EndProject"); } ss.WriteLine("Global"); ss.WriteLine("\tGlobalSection(SolutionConfiguration) = preSolution"); foreach(ConfigurationNode conf in solution.Configurations) { ss.WriteLine("\t\t{0} = {0}", conf.Name); } ss.WriteLine("\tEndGlobalSection"); ss.WriteLine("\tGlobalSection(ProjectDependencies) = postSolution"); foreach(ProjectNode project in solution.Projects) { for(int i = 0; i < project.References.Count; i++) { ReferenceNode refr = (ReferenceNode)project.References[i]; if(solution.ProjectsTable.ContainsKey(refr.Name)) { ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; ss.WriteLine("\t\t({{{0}}}).{1} = ({{{2}}})", project.Guid.ToString().ToUpper() , i, refProject.Guid.ToString().ToUpper() ); } } } ss.WriteLine("\tEndGlobalSection"); ss.WriteLine("\tGlobalSection(ProjectConfiguration) = postSolution"); foreach(ProjectNode project in solution.Projects) { foreach(ConfigurationNode conf in solution.Configurations) { ss.WriteLine("\t\t{{{0}}}.{1}.ActiveCfg = {1}|.NET", project.Guid.ToString().ToUpper(), conf.Name); ss.WriteLine("\t\t{{{0}}}.{1}.Build.0 = {1}|.NET", project.Guid.ToString().ToUpper(), conf.Name); } } ss.WriteLine("\tEndGlobalSection"); if(solution.Files != null) { ss.WriteLine("\tGlobalSection(SolutionItems) = postSolution"); foreach(string file in solution.Files) { ss.WriteLine("\t\t{0} = {0}", file); } ss.WriteLine("\tEndGlobalSection"); } ss.WriteLine("\tGlobalSection(ExtensibilityGlobals) = postSolution"); ss.WriteLine("\tEndGlobalSection"); ss.WriteLine("\tGlobalSection(ExtensibilityAddIns) = postSolution"); ss.WriteLine("\tEndGlobalSection"); ss.WriteLine("EndGlobal"); } m_Kernel.CurrentWorkingDirectory.Pop(); }