/// <summary> /// generates project.lock.json that tells compiler where to take dlls and source from /// and builds executable and copies all required dll's /// </summary> public BuildResult Build(GenerateResult generateResult, ILogger logger, Benchmark benchmark, IResolver resolver) { if (!DotNetCliCommandExecutor.ExecuteCommand( RestoreCommand, generateResult.ArtifactsPaths.BuildArtifactsDirectoryPath, logger, DefaultTimeout)) { return(BuildResult.Failure(generateResult, new Exception("dotnet restore has failed"))); } if (!DotNetCliCommandExecutor.ExecuteCommand( GetBuildCommand(TargetFrameworkMoniker), generateResult.ArtifactsPaths.BuildArtifactsDirectoryPath, logger, DefaultTimeout)) { // dotnet cli could have succesfully builded the program, but returned 1 as exit code because it had some warnings // so we need to check whether the exe exists or not, if it does then it is OK if (File.Exists(generateResult.ArtifactsPaths.ExecutablePath)) { return(BuildResult.Success(generateResult)); } return(BuildResult.Failure(generateResult)); } return(BuildResult.Success(generateResult)); }
public BuildResult Build(GenerateResult generateResult, BuildPartition buildPartition, ILogger logger) { string extraArguments = DotNetCliGenerator.GetCustomArguments(buildPartition.RepresentativeBenchmarkCase, buildPartition.Resolver); var restoreResult = DotNetCliCommandExecutor.ExecuteCommand( CustomDotNetCliPath, $"{RestoreCommand} {extraArguments}", generateResult.ArtifactsPaths.BuildArtifactsDirectoryPath, logger); if (!restoreResult.IsSuccess) { return(BuildResult.Failure(generateResult, new Exception(restoreResult.ProblemDescription))); } var buildResult = Build(generateResult, buildPartition.BuildConfiguration, extraArguments, logger); if (!buildResult.IsSuccess) { // dotnet cli could have successfully built the program, but returned 1 as exit code because it had some warnings // so we need to check whether the exe exists or not, if it does then it is OK if (File.Exists(generateResult.ArtifactsPaths.ExecutablePath)) { return(BuildResult.Success(generateResult)); } return(BuildResult.Failure(generateResult, new Exception(buildResult.ProblemDescription))); } return(BuildResult.Success(generateResult)); }
/// <summary> /// generates project.lock.json that tells compiler where to take dlls and source from /// and builds executable and copies all required dll's /// </summary> public BuildResult Build(GenerateResult generateResult, ILogger logger, Benchmark benchmark, IResolver resolver) { var restoreResult = DotNetCliCommandExecutor.ExecuteCommand( RestoreCommand, generateResult.ArtifactsPaths.BuildArtifactsDirectoryPath); logger.WriteLineInfo($"// dotnet restore took {restoreResult.ExecutionTime.TotalSeconds:0.##}s"); if (!restoreResult.IsSuccess) { return(BuildResult.Failure(generateResult, new Exception(restoreResult.ProblemDescription))); } var buildResult = Build(generateResult); logger.WriteLineInfo($"// dotnet build took {buildResult.ExecutionTime.TotalSeconds:0.##}s"); if (!buildResult.IsSuccess) { // dotnet cli could have succesfully builded the program, but returned 1 as exit code because it had some warnings // so we need to check whether the exe exists or not, if it does then it is OK if (File.Exists(generateResult.ArtifactsPaths.ExecutablePath)) { return(BuildResult.Success(generateResult)); } return(BuildResult.Failure(generateResult, new Exception(buildResult.ProblemDescription))); } return(BuildResult.Success(generateResult)); }
/// <summary> /// generates project.lock.json that tells compiler where to take dlls and source from /// and builds executable and copies all required dll's /// </summary> public BuildResult Build(GenerateResult generateResult, ILogger logger, Benchmark benchmark) { if (!DotNetCliCommandExecutor.ExecuteCommand( RestoreCommand, generateResult.DirectoryPath, logger, DefaultTimeout)) { return(new BuildResult(generateResult, false, new Exception("dotnet restore has failed"), null)); } if (!DotNetCliCommandExecutor.ExecuteCommand( GetBuildCommand(TargetFrameworkMonikerProvider(benchmark.Job.Framework)), generateResult.DirectoryPath, logger, DefaultTimeout)) { // dotnet cli could have succesfully builded the program, but returned 1 as exit code because it had some warnings // so we need to check whether the exe exists or not, if it does then it is OK var executablePath = BuildExecutablePath(generateResult, benchmark); if (File.Exists(executablePath)) { return(new BuildResult(generateResult, true, null, executablePath)); } return(new BuildResult(generateResult, false, new Exception("dotnet build has failed"), null)); } return(new BuildResult(generateResult, true, null, BuildExecutablePath(generateResult, benchmark))); }
private DotNetCliCommandExecutor.CommandResult Build(GenerateResult generateResult) { var withoutDependencies = DotNetCliCommandExecutor.ExecuteCommand( GetBuildCommand(TargetFrameworkMoniker, justTheProjectItself: true), generateResult.ArtifactsPaths.BuildArtifactsDirectoryPath); // at first we try to build the project without it's dependencies to save a LOT of time // in 99% of the cases it will work (the host process is running so it must be compiled!) if (withoutDependencies.IsSuccess) { return(withoutDependencies); } // but the host process might have different runtime or was build in Debug, not Release, // which requires all dependencies to be build anyway return(DotNetCliCommandExecutor.ExecuteCommand( GetBuildCommand(TargetFrameworkMoniker, justTheProjectItself: false), generateResult.ArtifactsPaths.BuildArtifactsDirectoryPath)); }
public BuildResult Build(GenerateResult generateResult, ILogger logger, Benchmark benchmark, IResolver resolver) { var extraArguments = DotNetCliGenerator.GetCustomArguments(benchmark, resolver); if (!string.IsNullOrEmpty(RestoreCommand)) { var restoreResult = DotNetCliCommandExecutor.ExecuteCommand( CustomDotNetCliPath, $"{RestoreCommand} {extraArguments}", generateResult.ArtifactsPaths.BuildArtifactsDirectoryPath); logger.WriteLineInfo($"// dotnet restore took {restoreResult.ExecutionTime.TotalSeconds:0.##}s"); if (!restoreResult.IsSuccess) { return(BuildResult.Failure(generateResult, new Exception(restoreResult.ProblemDescription))); } } var buildResult = Build( generateResult, benchmark.Job.ResolveValue(InfrastructureMode.BuildConfigurationCharacteristic, resolver), extraArguments); logger.WriteLineInfo($"// dotnet build/publish took {buildResult.ExecutionTime.TotalSeconds:0.##}s"); if (!buildResult.IsSuccess) { // dotnet cli could have succesfully builded the program, but returned 1 as exit code because it had some warnings // so we need to check whether the exe exists or not, if it does then it is OK if (File.Exists(generateResult.ArtifactsPaths.ExecutablePath)) { return(BuildResult.Success(generateResult)); } return(BuildResult.Failure(generateResult, new Exception(buildResult.ProblemDescription))); } return(BuildResult.Success(generateResult)); }
private DotNetCliCommandExecutor.CommandResult Build(GenerateResult generateResult, string configuration, string extraArguments, ILogger logger) { var withoutDependencies = DotNetCliCommandExecutor.ExecuteCommand( CustomDotNetCliPath, $"{GetBuildCommand(TargetFrameworkMoniker, true, configuration)} {extraArguments}", generateResult.ArtifactsPaths.BuildArtifactsDirectoryPath, logger); // at first we try to build the project without it's dependencies to save a LOT of time // in 99% of the cases it will work (the host process is running so it must be compiled!) if (withoutDependencies.IsSuccess) { return(withoutDependencies); } // but the host process might have different runtime or was build in Debug, not Release, // which requires all dependencies to be build anyway var withDependencies = DotNetCliCommandExecutor.ExecuteCommand( CustomDotNetCliPath, $"{GetBuildCommand(TargetFrameworkMoniker, false, configuration)} {extraArguments}", generateResult.ArtifactsPaths.BuildArtifactsDirectoryPath, logger); if (withDependencies.IsSuccess) { return(withDependencies); } // there are some crazy edge-cases, where executing dotnet build --no-restore AFTER dotnet restore will fail // an example: ML.NET has default values like Configuration = Debug in Directory.Build.props file // when we run dotnet restore for it, it restores for Debug. When we run dotnet build -c Release --no-restore, it fails because it can't find project.assets.json file // The problem is that dotnet cli does not allow to set the configuration from console arguments // But when we run dotnet build -c Release (without --no-restore) it's going to restore the right things for us ;) return(DotNetCliCommandExecutor.ExecuteCommand( CustomDotNetCliPath, $"{GetBuildCommand(TargetFrameworkMoniker, false, configuration)} {extraArguments}".Replace(" --no-restore", string.Empty), generateResult.ArtifactsPaths.BuildArtifactsDirectoryPath, logger)); }
private DotNetCliCommandExecutor.CommandResult Build(GenerateResult generateResult, string configuration, string extraArguments, ILogger logger) { var withoutDependencies = DotNetCliCommandExecutor.ExecuteCommand( CustomDotNetCliPath, $"{GetBuildCommand(TargetFrameworkMoniker, true, configuration)} {extraArguments}", generateResult.ArtifactsPaths.BuildArtifactsDirectoryPath, logger); // at first we try to build the project without it's dependencies to save a LOT of time // in 99% of the cases it will work (the host process is running so it must be compiled!) if (withoutDependencies.IsSuccess) { return(withoutDependencies); } // but the host process might have different runtime or was build in Debug, not Release, // which requires all dependencies to be build anyway return(DotNetCliCommandExecutor.ExecuteCommand( CustomDotNetCliPath, $"{GetBuildCommand(TargetFrameworkMoniker, false, configuration)} {extraArguments}", generateResult.ArtifactsPaths.BuildArtifactsDirectoryPath, logger)); }