private void Sort(AssemblyInformation node, List <AssemblyInformation> output, HashSet <AssemblyInformation> seen) { if (!seen.Add(node)) { return; } foreach (var dependency in node.GetDependencies()) { AssemblyInformation dependencyInfo; if (_universe.TryGetValue(dependency, out dependencyInfo)) { Sort(dependencyInfo, output, seen); } } if (!output.Contains(node)) { output.Add(node); } }
private bool GenerateNativeImage(AssemblyInformation assemblyInfo) { var retCrossgen = false; if (assemblyInfo.Closure.Any(a => !a.Generated)) { Console.WriteLine("Skipping {0}. Because one or more dependencies failed to generate", assemblyInfo.Name); return(false); } // Add the assembly itself to the closure var closure = assemblyInfo.Closure.Select(d => d.NativeImagePath) .Concat(new[] { assemblyInfo.AssemblyPath }); Console.WriteLine("Generating native images for {0}", assemblyInfo.Name); const string crossgenArgsTemplate = @"/Nologo /in ""{0}"" /out ""{1}"" /MissingDependenciesOK /Trusted_Platform_Assemblies ""{2}"""; // crossgen.exe /in {il-path}.dll /out {native-image-path} /MissingDependenciesOK /Trusted_Platform_Assemblies {closure} string args = null; // Treat mscorlib specially if (assemblyInfo.Name.Equals("mscorlib", StringComparison.OrdinalIgnoreCase)) { args = String.Format(crossgenArgsTemplate, assemblyInfo.AssemblyPath, assemblyInfo.NativeImagePath, assemblyInfo.AssemblyPath); } else { args = String.Format(crossgenArgsTemplate, assemblyInfo.AssemblyPath, assemblyInfo.NativeImagePath, String.Join(";", closure)); } // Make sure the target directory for the native image is there Directory.CreateDirectory(Path.GetDirectoryName(assemblyInfo.NativeImagePath)); retCrossgen = ExecuteCrossgen(_options.CrossgenPath, args, assemblyInfo.Name); if (retCrossgen) { assemblyInfo.Generated = true; } else { return(false); } if (_options.Symbols) { Console.WriteLine("Generating native pdb for {0}", assemblyInfo.Name); const string crossgenArgsTemplateCreatePdb = @"/Nologo /CreatePDB ""{0}"" /in ""{1}"" /out ""{2}"" /Trusted_Platform_Assemblies ""{3}"""; // crossgen.exe /CreatePDB {native-pdb-directory} /in {native-image-path}.dll /out {native-pdb-path} /Trusted_Platform_Assemblies {closure} string argsPdb = null; // Treat mscorlib specially if (assemblyInfo.Name.Equals("mscorlib", StringComparison.OrdinalIgnoreCase)) { argsPdb = String.Format(crossgenArgsTemplateCreatePdb, assemblyInfo.NativeImageDirectory, assemblyInfo.NativeImagePath, assemblyInfo.NativePdbPath, assemblyInfo.AssemblyPath); } else { // Note: for CreatePDB need the native image (not the il image) // Add the assembly itself to the closure var closurePdb = assemblyInfo.Closure.Select(d => d.NativeImagePath) .Concat(new[] { assemblyInfo.NativeImagePath }); argsPdb = String.Format(crossgenArgsTemplateCreatePdb, assemblyInfo.NativeImageDirectory, assemblyInfo.NativeImagePath, assemblyInfo.NativePdbPath, String.Join(";", closurePdb)); } retCrossgen = ExecuteCrossgen(_options.CrossgenPath, argsPdb, assemblyInfo.Name); } return(retCrossgen); }