public void Write(string filename) { var fullPath = Path.GetDirectoryName(filename) + "/"; using (var sln = new StreamWriter(filename)) { sln.WriteLine(); sln.WriteLine(header); foreach (var proj in libraries) { var unixProjFile = proj.csProjFilename.Replace("\\", "/"); var fullProjPath = Path.GetFullPath(unixProjFile); sln.WriteLine(project_start, proj.library, MsbuildGenerator.GetRelativePath(fullPath, fullProjPath), proj.projectGuid); sln.WriteLine(project_end); } sln.WriteLine("Global"); sln.WriteLine("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution"); sln.WriteLine("\t\tDebug|Any CPU = Debug|Any CPU"); sln.WriteLine("\t\tRelease|Any CPU = Release|Any CPU"); sln.WriteLine("\tEndGlobalSection"); sln.WriteLine("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution"); foreach (var proj in libraries) { var guid = proj.projectGuid; sln.WriteLine("\t\t{0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU", guid); sln.WriteLine("\t\t{0}.Debug|Any CPU.Build.0 = Debug|Any CPU", guid); sln.WriteLine("\t\t{0}.Release|Any CPU.ActiveCfg = Release|Any CPU", guid); sln.WriteLine("\t\t{0}.Release|Any CPU.Build.0 = Release|Any CPU", guid); } sln.WriteLine("\tEndGlobalSection"); sln.WriteLine("\tGlobalSection(SolutionProperties) = preSolution"); sln.WriteLine("\t\tHideSolutionNode = FALSE"); sln.WriteLine("\tEndGlobalSection"); sln.WriteLine("EndGlobal"); } }
static void Main(string [] args) { if (!File.Exists("genproj.cs")) { Console.WriteLine("This command must be executed from mono/msvc/scripts"); Environment.Exit(1); } if (args.Length == 1 && args [0].ToLower().Contains("-h")) { Console.WriteLine("Usage:"); Console.WriteLine("genproj.exe [visual_studio_release] [output_full_solutions]"); Console.WriteLine("If output_full_solutions is false, only the main System*.dll"); Console.WriteLine(" assemblies (and dependencies) is included in the solution."); Console.WriteLine("Example:"); Console.WriteLine("genproj.exe 2012 false"); Console.WriteLine("genproj.exe with no arguments is equivalent to 'genproj.exe 2012 true'\n\n"); Console.WriteLine("genproj.exe deps"); Console.WriteLine("Generates a Makefile dependency file from the projects input"); Environment.Exit(0); } var slnVersion = (args.Length > 0) ? args [0] : "2012"; bool fullSolutions = (args.Length > 1) ? bool.Parse(args [1]) : true; // To generate makefile depenedencies var makefileDeps = (args.Length > 0 && args [0] == "deps"); var sln_gen = new SlnGenerator(slnVersion); var four_five_sln_gen = new SlnGenerator(slnVersion); var projects = new Dictionary <string, MsbuildGenerator> (); var duplicates = new List <string> (); foreach (var project in GetProjects(makefileDeps)) { var library_output = project.Element("library_output").Value; projects [library_output] = new MsbuildGenerator(project); } foreach (var project in GetProjects(makefileDeps)) { var library_output = project.Element("library_output").Value; //Console.WriteLine ("=== {0} ===", library_output); var gen = projects [library_output]; try { var csproj = gen.Generate(library_output, projects); var csprojFilename = csproj.csProjFilename; if (!sln_gen.ContainsProjectIdentifier(csproj.library)) { sln_gen.Add(csproj); } else { duplicates.Add(csprojFilename); } } catch (Exception e) { Console.WriteLine("Error in {0}\n{1}", project, e); } } Func <MsbuildGenerator.VsCsproj, bool> additionalFilter; additionalFilter = fullSolutions ? (Func <MsbuildGenerator.VsCsproj, bool>)null : IsCommonLibrary; FillSolution(four_five_sln_gen, MsbuildGenerator.profile_4_x, projects.Values, additionalFilter); if (duplicates.Count() > 0) { var sb = new StringBuilder(); sb.AppendLine("WARNING: Skipped some project references, apparent duplicates in order.xml:"); foreach (var item in duplicates) { sb.AppendLine(item); } Console.WriteLine(sb.ToString()); } WriteSolution(four_five_sln_gen, Path.Combine("..", "..", MakeSolutionName(MsbuildGenerator.profile_4_x))); if (makefileDeps) { const string classDirPrefix = "./../../"; Console.WriteLine("here {0}", sln_gen.libraries.Count); foreach (var p in sln_gen.libraries) { string rebasedOutput = RebaseToClassDirectory(MsbuildGenerator.GetRelativePath("../../mcs/class", p.library_output)); Console.Write("{0}: ", rebasedOutput); foreach (var r in p.projReferences) { var lo = r.library_output; if (lo.StartsWith(classDirPrefix)) { lo = lo.Substring(classDirPrefix.Length); } else { lo = "<<ERROR-dependency is not a class library>>"; } Console.Write("{0} ", lo); } Console.Write("\n\t(cd {0}; make {1})", p.MsbuildGenerator.dir, p.library_output); Console.WriteLine("\n"); } } // A few other optional solutions // Solutions with 'everything' and the most common libraries used in development may be of interest //WriteSolution (sln_gen, "./mcs_full.sln"); //WriteSolution (small_full_sln_gen, "small_full.sln"); // The following may be useful if lacking visual studio or MonoDevelop, to bootstrap mono compiler self-hosting //WriteSolution (basic_sln_gen, "mcs_basic.sln"); //WriteSolution (build_sln_gen, "mcs_build.sln"); }