Exemplo n.º 1
0
        public Crossgen2Runner(BuildOptions options, Crossgen2RunnerOptions crossgen2RunnerOptions, IEnumerable <string> references)
            : base(options, references)
        {
            Crossgen2RunnerOptions = crossgen2RunnerOptions;

            // Some scenarios are easier to express when we give Crossgen2 a list of reference assemblies instead of directories,
            // so allow an override here.
            foreach (var reference in references)
            {
                if (File.Exists(reference))
                {
                    if (_referenceFolders.Count > 0)
                    {
                        // There's nothing wrong with this per se, but none of our current scenarios need it, so this is
                        // just a consistency check.
                        throw new ArgumentException($"A mix of files and directories was found in {references}");
                    }
                    _referenceFiles.Add(reference);
                }
            }

            // Set R2RTest parallelism to a low enough value that ensures that each Crossgen2 invocation gets to use its parallelism
            if (options.DegreeOfParallelism == 0)
            {
                options.DegreeOfParallelism = 2;
            }
        }
Exemplo n.º 2
0
        public int CompileSerpAssemblies()
        {
            Console.WriteLine($"Compiling serp in {_options.CompositeScenario} scenario");

            string serpRoot       = Directory.GetParent(SerpDir).Parent.Parent.Parent.FullName;
            string compileOutRoot = Path.Combine(serpRoot, CompileFolder);

            if (Directory.Exists(compileOutRoot))
            {
                Directory.Delete(compileOutRoot, true);
            }

            // Composite FX, Composite ASP.NET, Composite Serp core, Individual package assemblies
            List <ProcessInfo> fileCompilations = new List <ProcessInfo>();

            bool compositeFramework = false;
            bool compositeAspNet    = false;
            bool compositeSerpCore  = false;

            if (_options.CompositeScenario == SerpCompositeScenario.SerpAspNetSharedFramework)
            {
                compositeFramework = true;
                compositeAspNet    = true;
                compositeSerpCore  = true;
            }

            // Composite FX
            {
                List <string> frameworkCompileAssembliesBackup = BackupAndUseOriginalAssemblies(serpRoot, _frameworkCompileAssemblies);
                string        frameworkCompositeDll            = Path.Combine(_options.CoreRootDirectory.FullName, "framework-r2r.dll");
                if (File.Exists(frameworkCompositeDll))
                {
                    File.Delete(frameworkCompositeDll);
                }

                // Always restore the framework from the backup if present first since we run CG2 on it
                var backupFrameworkDir = Path.GetDirectoryName(GetBackupFile(serpRoot, frameworkCompositeDll));
                var backedUpFiles      = Directory.GetFiles(backupFrameworkDir, "*.dll", SearchOption.AllDirectories);
                foreach (var file in backedUpFiles)
                {
                    string destinationFile = GetOriginalFile(serpRoot, file);
                    File.Copy(file, destinationFile, true);
                }

                if (compositeFramework)
                {
                    string frameworkCompositeDllCompile     = GetCompileFile(serpRoot, frameworkCompositeDll);
                    Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                    {
                        Composite = true
                    };
                    var runner             = new Crossgen2Runner(_options, crossgen2Options, new List <string>());
                    var compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, frameworkCompositeDllCompile, frameworkCompileAssembliesBackup));
                    fileCompilations.Add(compilationProcess);
                }
                else
                {
                    Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                    {
                        Composite = false
                    };
                    var runner = new Crossgen2Runner(_options, crossgen2Options, new List <string>());
                    foreach (string assembly in frameworkCompileAssembliesBackup)
                    {
                        string dllCompile         = GetCompileFile(serpRoot, assembly);
                        var    compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, dllCompile, new string[] { assembly }));
                        fileCompilations.Add(compilationProcess);
                    }
                }
            }

            // Composite Asp.Net
            {
                List <string> aspCombinedReferencesBackup = BackupAndUseOriginalAssemblies(serpRoot, new List <string>(_frameworkReferenceAssemblies));
                List <string> aspCompileAssembliesBackup  = BackupAndUseOriginalAssemblies(serpRoot, _aspCompileAssemblies);
                string        aspCompositeDll             = Path.Combine(_options.AspNetPath.FullName, "asp-r2r.dll");
                if (File.Exists(aspCompositeDll))
                {
                    File.Delete(aspCompositeDll);
                }

                if (compositeAspNet)
                {
                    string aspCompositeDllCompile           = GetCompileFile(serpRoot, aspCompositeDll);
                    Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                    {
                        Composite = true, PartialComposite = true
                    };
                    var runner             = new Crossgen2Runner(_options, crossgen2Options, aspCombinedReferencesBackup);
                    var compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, aspCompositeDllCompile, aspCompileAssembliesBackup));
                    fileCompilations.Add(compilationProcess);
                }
                else
                {
                    Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                    {
                        Composite = false
                    };
                    var runner = new Crossgen2Runner(_options, crossgen2Options, aspCombinedReferencesBackup);
                    foreach (string assembly in aspCompileAssembliesBackup)
                    {
                        string dllCompile         = GetCompileFile(serpRoot, assembly);
                        var    compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, dllCompile, new string[] { assembly }));
                        fileCompilations.Add(compilationProcess);
                    }
                }
            }

            // Composite Serp core
            {
                List <string> coreCombinedReferences = new List <string>();
                coreCombinedReferences.AddRange(_coreReferenceAssemblies);
                coreCombinedReferences.AddRange(_aspReferenceAssemblies);
                coreCombinedReferences.AddRange(_frameworkReferenceAssemblies);
                List <string> coreCombinedReferencesBackup = BackupAndUseOriginalAssemblies(serpRoot, coreCombinedReferences);
                List <string> coreCompileAssembliesBackup  = BackupAndUseOriginalAssemblies(serpRoot, _coreCompileAssemblies);
                string        serpCompositeDll             = Path.Combine(BinDir, "serp-r2r.dll");
                if (File.Exists(serpCompositeDll))
                {
                    File.Delete(serpCompositeDll);
                }

                if (compositeSerpCore)
                {
                    string coreCompositeDllCompile          = GetCompileFile(serpRoot, serpCompositeDll);
                    Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                    {
                        Composite = true, PartialComposite = true
                    };
                    var runner             = new Crossgen2Runner(_options, crossgen2Options, coreCombinedReferencesBackup);
                    var compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, coreCompositeDllCompile, coreCompileAssembliesBackup));
                    fileCompilations.Add(compilationProcess);
                }
                else
                {
                    Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                    {
                        Composite = false
                    };
                    var runner = new Crossgen2Runner(_options, crossgen2Options, coreCombinedReferencesBackup);
                    foreach (string assembly in coreCompileAssembliesBackup)
                    {
                        string dllCompile         = GetCompileFile(serpRoot, assembly);
                        var    compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, dllCompile, new string[] { assembly }));
                        fileCompilations.Add(compilationProcess);
                    }
                }
            }

            // Individual Serp package assemblies
            {
                List <string> packageCombinedReferences = new List <string>();
                packageCombinedReferences.AddRange(_packageReferenceAssemblies);
                packageCombinedReferences.AddRange(_coreReferenceAssemblies);
                packageCombinedReferences.AddRange(_aspReferenceAssemblies);
                packageCombinedReferences.AddRange(_frameworkReferenceAssemblies);
                List <string> packageCombinedReferencesBackup = BackupAndUseOriginalAssemblies(serpRoot, packageCombinedReferences);
                List <string> packageCompileAssembliesBackup  = BackupAndUseOriginalAssemblies(serpRoot, _packageCompileAssemblies);

                Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                {
                    Composite = false
                };
                var runner = new Crossgen2Runner(_options, crossgen2Options, packageCombinedReferencesBackup);
                foreach (string assembly in packageCompileAssembliesBackup)
                {
                    string dllCompile         = GetCompileFile(serpRoot, assembly);
                    var    compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, dllCompile, new string[] { assembly }));
                    fileCompilations.Add(compilationProcess);
                }
            }

            ParallelRunner.Run(fileCompilations, _options.DegreeOfParallelism);

            bool success = true;

            foreach (var compilationProcess in fileCompilations)
            {
                if (!compilationProcess.Succeeded)
                {
                    success = false;
                    Console.WriteLine($"Failed compiling {compilationProcess.Parameters.OutputFileName}");
                }
            }

            if (!success)
            {
                return(1);
            }

            // Move everything we compiled to the main directory structure
            var compiledFiles = Directory.GetFiles(Path.Combine(serpRoot, CompileFolder), "*.dll", SearchOption.AllDirectories);

            foreach (var file in compiledFiles)
            {
                string destinationFile = GetOriginalFile(serpRoot, file);
                File.Move(file, destinationFile, true);
            }

            return(success ? 0 : 1);
        }
Exemplo n.º 3
0
        public int CompileSerpAssemblies()
        {
            Console.WriteLine($"Compiling serp in {_options.CompositeScenario} scenario");

            string serpRoot       = Directory.GetParent(SerpDir).Parent.Parent.Parent.FullName;
            string compileOutRoot = Path.Combine(serpRoot, CompileFolder);

            if (Directory.Exists(compileOutRoot))
            {
                Directory.Delete(compileOutRoot, true);
            }

            // Composite FX, Composite ASP.NET, Composite Serp core, Individual package assemblies
            List <ProcessInfo> fileCompilations = new List <ProcessInfo>();

            bool combinedComposite  = false;
            bool compositeFramework = false;
            bool compositeAspNet    = false;
            bool compositeSerpCore  = false;

            if (_options.CompositeScenario == SerpCompositeScenario.SerpAspNetSharedFramework)
            {
                compositeFramework = true;
                compositeAspNet    = true;
                compositeSerpCore  = true;
            }
            if (_options.CompositeScenario == SerpCompositeScenario.SerpAspNetSharedFrameworkCompositeAndPackagesComposite)
            {
                combinedComposite = true;
            }

            // Single composite image for Serp, Asp, Fx
            {
                if (combinedComposite)
                {
                    List <string>    combinedCompileAssemblies = new List <string>();
                    HashSet <string> simpleNameList            = new HashSet <string>();
                    combinedCompileAssemblies.AddRange(FilterAssembliesNoSimpleNameDuplicates(simpleNameList, _coreCompileAssemblies));
                    combinedCompileAssemblies.AddRange(FilterAssembliesNoSimpleNameDuplicates(simpleNameList, _aspCompileAssemblies));
                    combinedCompileAssemblies.AddRange(FilterAssembliesNoSimpleNameDuplicates(simpleNameList, _frameworkCompileAssemblies));

                    List <string> combinedCompileAssembliesBackup = BackupAndUseOriginalAssemblies(serpRoot, combinedCompileAssemblies);
                    string        frameworkCompositeDll           = Path.Combine(_options.CoreRootDirectory.FullName, FrameworkCompositeFilename);
                    if (File.Exists(frameworkCompositeDll))
                    {
                        File.Delete(frameworkCompositeDll);
                    }

                    string frameworkCompositeDllCompile     = GetCompileFile(serpRoot, frameworkCompositeDll);
                    Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                    {
                        Composite = true, CompositeRoot = GetBackupFile(serpRoot, SerpDir)
                    };
                    var runner             = new Crossgen2Runner(_options, crossgen2Options, combinedCompileAssembliesBackup);
                    var compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, frameworkCompositeDllCompile, combinedCompileAssembliesBackup));
                    fileCompilations.Add(compilationProcess);
                }
            }

            if (!combinedComposite)
            {
                // Composite FX
                {
                    List <string> frameworkCompileAssembliesBackup = BackupAndUseOriginalAssemblies(serpRoot, _frameworkCompileAssemblies);
                    string        frameworkCompositeDll            = Path.Combine(_options.CoreRootDirectory.FullName, FrameworkCompositeFilename);
                    if (File.Exists(frameworkCompositeDll))
                    {
                        File.Delete(frameworkCompositeDll);
                    }

                    // Always restore the framework from the backup if present first since we run CG2 on it
                    var backupFrameworkDir = Path.GetDirectoryName(GetBackupFile(serpRoot, frameworkCompositeDll));
                    var backedUpFiles      = Directory.GetFiles(backupFrameworkDir, "*.dll", SearchOption.AllDirectories);
                    foreach (var file in backedUpFiles)
                    {
                        string destinationFile = GetOriginalFile(serpRoot, file);
                        File.Copy(file, destinationFile, true);
                    }

                    if (compositeFramework)
                    {
                        string frameworkCompositeDllCompile     = GetCompileFile(serpRoot, frameworkCompositeDll);
                        Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                        {
                            Composite = true
                        };
                        var runner             = new Crossgen2Runner(_options, crossgen2Options, new List <string>());
                        var compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, frameworkCompositeDllCompile, frameworkCompileAssembliesBackup));
                        fileCompilations.Add(compilationProcess);
                    }
                    else
                    {
                        Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                        {
                            Composite = false
                        };
                        var runner = new Crossgen2Runner(_options, crossgen2Options, new List <string>());
                        foreach (string assembly in frameworkCompileAssembliesBackup)
                        {
                            string dllCompile         = GetCompileFile(serpRoot, assembly);
                            var    compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, dllCompile, new string[] { assembly }));
                            fileCompilations.Add(compilationProcess);
                        }
                    }
                }

                // Composite Asp.Net
                {
                    List <string> aspCombinedReferences = new List <string>();
                    aspCombinedReferences.AddRange(_aspReferenceAssemblies);
                    aspCombinedReferences.AddRange(_frameworkCompileAssemblies);
                    List <string> aspCombinedReferencesBackup = BackupAndUseOriginalAssemblies(serpRoot, aspCombinedReferences);
                    List <string> aspCompileAssembliesBackup  = BackupAndUseOriginalAssemblies(serpRoot, _aspCompileAssemblies);
                    string        aspCompositeDll             = Path.Combine(_options.AspNetPath.FullName, "asp-r2r.dll");
                    if (File.Exists(aspCompositeDll))
                    {
                        File.Delete(aspCompositeDll);
                    }

                    if (compositeAspNet)
                    {
                        string aspCompositeDllCompile           = GetCompileFile(serpRoot, aspCompositeDll);
                        Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                        {
                            Composite = true, PartialComposite = true
                        };
                        var runner             = new Crossgen2Runner(_options, crossgen2Options, aspCombinedReferencesBackup);
                        var compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, aspCompositeDllCompile, aspCompileAssembliesBackup));
                        fileCompilations.Add(compilationProcess);
                    }
                    else
                    {
                        Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                        {
                            Composite = false
                        };
                        var runner = new Crossgen2Runner(_options, crossgen2Options, aspCombinedReferencesBackup);
                        foreach (string assembly in aspCompileAssembliesBackup)
                        {
                            string dllCompile         = GetCompileFile(serpRoot, assembly);
                            var    compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, dllCompile, new string[] { assembly }));
                            fileCompilations.Add(compilationProcess);
                        }
                    }
                }

                // Composite Serp core
                {
                    List <string> coreCombinedReferences = new List <string>();
                    coreCombinedReferences.AddRange(_coreReferenceAssemblies);
                    coreCombinedReferences.AddRange(_aspReferenceAssemblies);
                    coreCombinedReferences.AddRange(_frameworkReferenceAssemblies);
                    List <string> coreCombinedReferencesBackup = BackupAndUseOriginalAssemblies(serpRoot, coreCombinedReferences);
                    List <string> coreCompileAssembliesBackup  = BackupAndUseOriginalAssemblies(serpRoot, _coreCompileAssemblies);
                    string        serpCompositeDll             = Path.Combine(BinDir, "serp-r2r.dll");
                    if (File.Exists(serpCompositeDll))
                    {
                        File.Delete(serpCompositeDll);
                    }

                    if (compositeSerpCore)
                    {
                        string coreCompositeDllCompile          = GetCompileFile(serpRoot, serpCompositeDll);
                        Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                        {
                            Composite = true, PartialComposite = true
                        };
                        var runner             = new Crossgen2Runner(_options, crossgen2Options, coreCombinedReferencesBackup);
                        var compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, coreCompositeDllCompile, coreCompileAssembliesBackup));
                        fileCompilations.Add(compilationProcess);
                    }
                    else
                    {
                        Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                        {
                            Composite = false
                        };
                        var runner = new Crossgen2Runner(_options, crossgen2Options, coreCombinedReferencesBackup);
                        foreach (string assembly in coreCompileAssembliesBackup)
                        {
                            string dllCompile         = GetCompileFile(serpRoot, assembly);
                            var    compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, dllCompile, new string[] { assembly }));
                            fileCompilations.Add(compilationProcess);
                        }
                    }
                }
            }

            string packagesCompositeDirectory = null;

            // Individual Serp package assemblies
            {
                List <string>    packageCombinedReferences = new List <string>();
                HashSet <string> simpleNameList            = new HashSet <string>();
                packageCombinedReferences.AddRange(FilterAssembliesNoSimpleNameDuplicates(simpleNameList, _packageReferenceAssemblies));
                packageCombinedReferences.AddRange(FilterAssembliesNoSimpleNameDuplicates(simpleNameList, _coreReferenceAssemblies));
                packageCombinedReferences.AddRange(FilterAssembliesNoSimpleNameDuplicates(simpleNameList, _aspReferenceAssemblies));
                packageCombinedReferences.AddRange(FilterAssembliesNoSimpleNameDuplicates(simpleNameList, _frameworkReferenceAssemblies));
                List <string> packageCombinedReferencesBackup = BackupAndUseOriginalAssemblies(serpRoot, packageCombinedReferences);
                List <string> packageCompileAssembliesBackup  = BackupAndUseOriginalAssemblies(serpRoot, _packageCompileAssemblies);

                string packagesCompositeDll = Path.Combine(_options.CoreRootDirectory.FullName, PackagesCompositeFilename);
                packagesCompositeDirectory = SerpDir;
                if (File.Exists(packagesCompositeDll))
                {
                    File.Delete(packagesCompositeDll);
                }

                if (combinedComposite)
                {
                    string packagesCompositeDllCompile      = GetCompileFile(serpRoot, packagesCompositeDll);
                    Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                    {
                        Composite = true, CompositeRoot = GetBackupFile(serpRoot, SerpDir), PartialComposite = true
                    };
                    var runner             = new Crossgen2Runner(_options, crossgen2Options, packageCombinedReferencesBackup);
                    var compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, packagesCompositeDllCompile, packageCompileAssembliesBackup));
                    fileCompilations.Add(compilationProcess);
                }
                else
                {
                    Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                    {
                        Composite = false
                    };
                    var runner = new Crossgen2Runner(_options, crossgen2Options, packageCombinedReferencesBackup);
                    foreach (string assembly in packageCompileAssembliesBackup)
                    {
                        string dllCompile         = GetCompileFile(serpRoot, assembly);
                        var    compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, dllCompile, new string[] { assembly }));
                        fileCompilations.Add(compilationProcess);
                    }
                }
            }

            ParallelRunner.Run(fileCompilations, _options.DegreeOfParallelism);

            bool success = true;

            foreach (var compilationProcess in fileCompilations)
            {
                if (!compilationProcess.Succeeded)
                {
                    success = false;
                    Console.WriteLine($"Failed compiling {compilationProcess.Parameters.OutputFileName}");
                }
            }

            if (!success)
            {
                return(1);
            }


            if (combinedComposite)
            {
                // For combined composite, move the component assemblies we added the R2R header from the composite out folder
                // to the correct compile tree destination folder so they get copied into the right place
                string compositeOutputRootDir = GetCompileFile(serpRoot, _options.CoreRootDirectory.FullName);
                string frameworkCompositeDll  = Path.Combine(compositeOutputRootDir, FrameworkCompositeFilename);
                Debug.Assert(File.Exists(frameworkCompositeDll));
                var compiledCompositeFiles = Directory.GetFiles(compositeOutputRootDir, "*.dll", SearchOption.AllDirectories);
                foreach (var componentAssembly in compiledCompositeFiles)
                {
                    if (Path.GetFileName(componentAssembly).Equals(FrameworkCompositeFilename))
                    {
                        continue;
                    }

                    if (Path.GetFileName(componentAssembly).Equals(PackagesCompositeFilename))
                    {
                        continue;
                    }

                    string assemblyRelativePath = Path.GetRelativePath(compositeOutputRootDir, componentAssembly);
                    string destinationFile      = Path.Combine(SerpDir, assemblyRelativePath);
                    Debug.Assert(File.Exists(GetBackupFile(serpRoot, destinationFile)));
                    File.Move(componentAssembly, destinationFile, true);
                }
            }

            // Move everything we compiled to the main directory structure
            var compiledFiles = Directory.GetFiles(Path.Combine(serpRoot, CompileFolder), "*.dll", SearchOption.AllDirectories);

            foreach (var file in compiledFiles)
            {
                string destinationFile = GetOriginalFile(serpRoot, file);
                File.Move(file, destinationFile, true);
            }

            return(success ? 0 : 1);
        }
Exemplo n.º 4
0
        public int CompileSerpAssemblies()
        {
            Console.WriteLine("Compiling serp in " + (_options.Composite ? "composite" : "single assembly") + " mode");

            string serpRoot       = Directory.GetParent(SerpDir).Parent.Parent.Parent.FullName;
            string compileOutRoot = Path.Combine(serpRoot, CompileFolder);

            if (Directory.Exists(compileOutRoot))
            {
                Directory.Delete(compileOutRoot, true);
            }

            List <ProcessInfo> fileCompilations = new List <ProcessInfo>();

            // Single composite image for all of Serp
            if (_options.Composite)
            {
                List <string>    combinedCompileAssemblies = new List <string>();
                HashSet <string> simpleNameList            = new HashSet <string>();
                combinedCompileAssemblies.AddRange(FilterAssembliesNoSimpleNameDuplicates(simpleNameList, _coreCompileAssemblies));
                combinedCompileAssemblies.AddRange(FilterAssembliesNoSimpleNameDuplicates(simpleNameList, _aspCompileAssemblies));
                combinedCompileAssemblies.AddRange(FilterAssembliesNoSimpleNameDuplicates(simpleNameList, _frameworkCompileAssemblies));
                combinedCompileAssemblies.AddRange(FilterAssembliesNoSimpleNameDuplicates(simpleNameList, _packageCompileAssemblies));

                List <string> combinedCompileAssembliesBackup = BackupAndUseOriginalAssemblies(serpRoot, combinedCompileAssemblies);
                string        compositeDllPath = Path.Combine(BinDir, SerpCompositeFilename);
                if (File.Exists(compositeDllPath))
                {
                    File.Delete(compositeDllPath);
                }

                string compositeDllCompile = GetCompileFile(serpRoot, compositeDllPath);
                Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                {
                    Composite = true, CompositeRoot = GetBackupFile(serpRoot, SerpDir), PartialComposite = true
                };
                var runner             = new Crossgen2Runner(_options, crossgen2Options, combinedCompileAssembliesBackup);
                var compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, compositeDllCompile, combinedCompileAssembliesBackup));
                fileCompilations.Add(compilationProcess);
            }
            else
            {
                // Framework assemblies
                {
                    List <string> frameworkCompileAssembliesBackup = BackupAndUseOriginalAssemblies(serpRoot, _frameworkCompileAssemblies);

                    Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                    {
                        Composite = false
                    };
                    var runner = new Crossgen2Runner(_options, crossgen2Options, new List <string>());
                    foreach (string assembly in frameworkCompileAssembliesBackup)
                    {
                        string dllCompile         = GetCompileFile(serpRoot, assembly);
                        var    compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, dllCompile, new string[] { assembly }));
                        fileCompilations.Add(compilationProcess);
                    }
                }

                // Asp.Net
                {
                    List <string> aspCombinedReferences = new List <string>();
                    aspCombinedReferences.AddRange(_aspReferenceAssemblies);
                    aspCombinedReferences.AddRange(_frameworkCompileAssemblies);
                    List <string> aspCombinedReferencesBackup = BackupAndUseOriginalAssemblies(serpRoot, aspCombinedReferences);
                    List <string> aspCompileAssembliesBackup  = BackupAndUseOriginalAssemblies(serpRoot, _aspCompileAssemblies);

                    Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                    {
                        Composite = false
                    };
                    var runner = new Crossgen2Runner(_options, crossgen2Options, aspCombinedReferencesBackup);
                    foreach (string assembly in aspCompileAssembliesBackup)
                    {
                        string dllCompile         = GetCompileFile(serpRoot, assembly);
                        var    compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, dllCompile, new string[] { assembly }));
                        fileCompilations.Add(compilationProcess);
                    }
                }

                // Serp core
                {
                    List <string> coreCombinedReferences = new List <string>();
                    coreCombinedReferences.AddRange(_coreReferenceAssemblies);
                    coreCombinedReferences.AddRange(_aspReferenceAssemblies);
                    coreCombinedReferences.AddRange(_frameworkReferenceAssemblies);
                    List <string> coreCombinedReferencesBackup = BackupAndUseOriginalAssemblies(serpRoot, coreCombinedReferences);
                    List <string> coreCompileAssembliesBackup  = BackupAndUseOriginalAssemblies(serpRoot, _coreCompileAssemblies);

                    Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                    {
                        Composite = false
                    };
                    var runner = new Crossgen2Runner(_options, crossgen2Options, coreCombinedReferencesBackup);
                    foreach (string assembly in coreCompileAssembliesBackup)
                    {
                        string dllCompile         = GetCompileFile(serpRoot, assembly);
                        var    compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, dllCompile, new string[] { assembly }));
                        fileCompilations.Add(compilationProcess);
                    }
                }

                // Individual Serp package assemblies
                {
                    List <string>    packageCombinedReferences = new List <string>();
                    HashSet <string> simpleNameList            = new HashSet <string>();
                    packageCombinedReferences.AddRange(FilterAssembliesNoSimpleNameDuplicates(simpleNameList, _packageReferenceAssemblies));
                    packageCombinedReferences.AddRange(FilterAssembliesNoSimpleNameDuplicates(simpleNameList, _coreReferenceAssemblies));
                    packageCombinedReferences.AddRange(FilterAssembliesNoSimpleNameDuplicates(simpleNameList, _aspReferenceAssemblies));
                    packageCombinedReferences.AddRange(FilterAssembliesNoSimpleNameDuplicates(simpleNameList, _frameworkReferenceAssemblies));
                    List <string> packageCombinedReferencesBackup = BackupAndUseOriginalAssemblies(serpRoot, packageCombinedReferences);
                    List <string> packageCompileAssembliesBackup  = BackupAndUseOriginalAssemblies(serpRoot, _packageCompileAssemblies);

                    Crossgen2RunnerOptions crossgen2Options = new Crossgen2RunnerOptions()
                    {
                        Composite = false
                    };
                    var runner = new Crossgen2Runner(_options, crossgen2Options, packageCombinedReferencesBackup);
                    foreach (string assembly in packageCompileAssembliesBackup)
                    {
                        string dllCompile         = GetCompileFile(serpRoot, assembly);
                        var    compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, dllCompile, new string[] { assembly }));
                        fileCompilations.Add(compilationProcess);
                    }
                }
            }

            ParallelRunner.Run(fileCompilations, _options.DegreeOfParallelism);

            bool success = true;

            foreach (var compilationProcess in fileCompilations)
            {
                if (!compilationProcess.Succeeded)
                {
                    success = false;
                    Console.WriteLine($"Failed compiling {compilationProcess.Parameters.OutputFileName}");
                }
            }

            if (!success)
            {
                return(1);
            }

            if (_options.Composite)
            {
                // For combined composite, move the component assemblies we added the R2R header from the composite out folder
                // to the correct compile tree destination folder so they get copied into the right place
                string compositeOutputRootDir = GetCompileFile(serpRoot, BinDir);
                string frameworkCompositeDll  = Path.Combine(compositeOutputRootDir, SerpCompositeFilename);
                Debug.Assert(File.Exists(frameworkCompositeDll));
                var compiledCompositeFiles = Directory.GetFiles(compositeOutputRootDir, "*.dll", SearchOption.AllDirectories);
                foreach (var componentAssembly in compiledCompositeFiles)
                {
                    if (Path.GetFileName(componentAssembly).Equals(SerpCompositeFilename))
                    {
                        continue;
                    }

                    string assemblyRelativePath = Path.GetRelativePath(compositeOutputRootDir, componentAssembly);
                    string destinationFile      = Path.Combine(SerpDir, assemblyRelativePath);
                    Debug.Assert(File.Exists(GetBackupFile(serpRoot, destinationFile)));
                    File.Move(componentAssembly, destinationFile, true);
                }
            }

            // Move everything we compiled to the main directory structure
            var compiledFiles = Directory.GetFiles(Path.Combine(serpRoot, CompileFolder), "*.dll", SearchOption.AllDirectories);

            foreach (var file in compiledFiles)
            {
                string destinationFile = GetOriginalFile(serpRoot, file);
                File.Move(file, destinationFile, true);
            }

            return(success ? 0 : 1);
        }