public ProcessParameters CompilationR2RDumpProcess(string compiledExecutable, bool naked) { if (_options.R2RDumpPath == null) { return(null); } StringBuilder commonBuilder = new StringBuilder(); commonBuilder.Append($@"""{_options.R2RDumpPath.FullName}"""); commonBuilder.Append(" --normalize"); commonBuilder.Append(" --sc"); commonBuilder.Append(" --disasm"); foreach (string referencePath in _options.ReferencePaths()) { commonBuilder.Append($@" --rp ""{referencePath}"""); } if (_options.CoreRootDirectory != null) { commonBuilder.Append($@" --rp ""{_options.CoreRootDirectory.FullName}"""); } commonBuilder.Append($@" --in ""{compiledExecutable}"""); StringBuilder builder = new StringBuilder(commonBuilder.ToString()); if (naked) { builder.Append(" --naked"); } string outputFileName = compiledExecutable + (naked ? ".naked.r2r" : ".raw.r2r"); builder.Append($@" --out ""{outputFileName}"""); ProcessParameters param = new ProcessParameters(); param.ProcessPath = "dotnet"; param.Arguments = builder.ToString(); param.TimeoutMilliseconds = R2RDumpTimeoutMilliseconds; param.LogPath = compiledExecutable + (naked ? ".naked.r2r.log" : ".raw.r2r.log"); param.InputFileNames = new string[] { compiledExecutable }; param.OutputFileName = outputFileName; try { param.CompilationCostHeuristic = new FileInfo(compiledExecutable).Length; } catch (Exception ex) { Console.Error.WriteLine("File not found: {0}: {1}", compiledExecutable, ex); param.CompilationCostHeuristic = 0; } return(param); }
public static int CompileNuget(BuildOptions options) { if (options.CoreRootDirectory == null) { Console.Error.WriteLine("--core-root-directory (--cr) is a required argument."); return(1); } // We don't want to launch these apps when building the folder set below options.NoExe = true; options.NoJit = true; options.InputDirectory = options.OutputDirectory; IList <string> packageList = ReadPackageNames(options.PackageList.FullName); if (options.OutputDirectory == null) { Console.Error.WriteLine("--output-directory is a required argument."); return(1); } IEnumerable <string> referencePaths = options.ReferencePaths(); IEnumerable <CompilerRunner> runners = options.CompilerRunners(false); if (!options.Exe) { PathExtensions.DeleteOutputFolders(options.OutputDirectory.FullName, options.CoreRootDirectory.FullName, runners, recursive: false); } string nugetOutputFolder = Path.Combine(options.OutputDirectory.FullName, "nuget.out"); Directory.CreateDirectory(nugetOutputFolder); var publishedAppFoldersToCompile = new List <BuildFolder>(); using (StreamWriter nugetLog = File.CreateText(Path.Combine(nugetOutputFolder, "nugetLog.txt"))) { foreach (var package in packageList) { nugetLog.WriteLine($"Creating empty app for {package}"); // Create an app folder string appFolder = Path.Combine(nugetOutputFolder, $"{package}.TestApp"); Directory.CreateDirectory(appFolder); int exitCode = DotnetCli.New(appFolder, "console", nugetLog); if (exitCode != 0) { nugetLog.WriteLine($"dotnet new console for {package} failed with exit code {exitCode}"); continue; } exitCode = DotnetCli.AddPackage(appFolder, package, nugetLog); if (exitCode != 0) { nugetLog.WriteLine($"dotnet add package {package} failed with exit code {exitCode}"); continue; } exitCode = DotnetCli.Publish(appFolder, nugetLog); if (exitCode != 0) { nugetLog.WriteLine($"dotnet publish failed with exit code {exitCode}"); continue; } // This is not a reliable way of building the publish folder string publishFolder = Path.Combine(appFolder, @"artifacts\Debug\net5.0\publish"); if (!Directory.Exists(publishFolder)) { nugetLog.WriteLine($"Could not find folder {publishFolder} containing the published app."); continue; } publishedAppFoldersToCompile.Add(BuildFolder.FromDirectory(publishFolder, runners, appFolder, options)); } BuildFolderSet folderSet = new BuildFolderSet(publishedAppFoldersToCompile, runners, options); bool success = folderSet.Build(); folderSet.WriteLogs(); if (!options.NoCleanup && !options.Exe) { PathExtensions.DeleteOutputFolders(options.OutputDirectory.FullName, options.CoreRootDirectory.FullName, runners, recursive: false); } return(success ? 0 : 1); } }
public JitRunner(BuildOptions options) : base(options, new string[] { options.CoreRootDirectory.FullName }.Concat(options.ReferencePaths())) { }