Ejemplo n.º 1
0
        public BuildResult Build(GenerateResult generateResult, ILogger logger, Benchmark benchmark, IResolver resolver)
        {
            var extraArguments = DotNetCliGenerator.GetCustomArguments(benchmark, resolver);

            var configurationName = benchmark.Job.ResolveValue(InfrastructureMode.BuildConfigurationCharacteristic, resolver);

            var publishResult = DotNetCliCommandExecutor.ExecuteCommand(
                CustomDotNetCliPath,
                $"publish -c {configurationName} {extraArguments}",
                generateResult.ArtifactsPaths.BuildArtifactsDirectoryPath);

            if (!publishResult.IsSuccess &&
                !File.Exists(generateResult.ArtifactsPaths.ExecutablePath)) // dotnet cli could have succesfully builded the program, but returned 1 as exit code because it had some warnings
            {
                return(BuildResult.Failure(generateResult, new Exception(publishResult.ProblemDescription)));
            }

            if (FilesToCopy != null)
            {
                var destinationFolder = Path.GetDirectoryName(generateResult.ArtifactsPaths.ExecutablePath);
                foreach (var fileToCopy in FilesToCopy)
                {
                    File.Copy(fileToCopy, Path.Combine(destinationFolder, Path.GetFileName(fileToCopy)), overwrite: true);
                }
            }

            return(BuildResult.Success(generateResult));
        }
Ejemplo n.º 2
0
        private ExecuteResult Execute(Benchmark benchmark, ILogger logger, string workingDirectory, IDiagnoser diagnoser,
                                      IResolver resolver)
        {
            using (var process = new Process {
                StartInfo = DotNetCliCommandExecutor.BuildStartInfo(workingDirectory, "run --configuration Release")
            })                                                                                                                                         // there is only one framework in the .csproj, no need to specify it
            {
                var loggerWithDiagnoser = new SynchronousProcessOutputLoggerWithDiagnoser(logger, process, diagnoser, benchmark);

                //consoleHandler.SetProcess(process); // todo

                process.Start();

                //process.EnsureHighPriority(logger); // todo
                //if (benchmark.Job.Env.HasValue(EnvMode.AffinityCharacteristic))
                //{
                //    process.EnsureProcessorAffinity(benchmark.Job.Env.Affinity);
                //}

                loggerWithDiagnoser.ProcessInput();

                process.WaitForExit(); // should we add timeout here?

                if (process.ExitCode == 0)
                {
                    return(new ExecuteResult(true, process.ExitCode, loggerWithDiagnoser.LinesWithResults, loggerWithDiagnoser.LinesWithExtraOutput));
                }

                return(new ExecuteResult(true, process.ExitCode, new string[0], new string[0]));
            }
        }