private static int BuildAndDispatchDependencyCommand( string[] args, NuGetFramework frameworkToUse, string projectPath, string buildBasePath, string configuration) { if (frameworkToUse == null) { throw new ArgumentNullException(nameof(frameworkToUse)); } if (string.IsNullOrEmpty(projectPath)) { throw new ArgumentNullException(nameof(projectPath)); } var buildResult = DotNetBuildCommandHelper.Build( projectPath, configuration, frameworkToUse, buildBasePath); if (buildResult.Result.ExitCode != 0) { //Build failed. // Stop the process here. _logger.LogMessage("Build Failed"); _logger.LogMessage(string.Join(Environment.NewLine, buildResult.StdErr), LogMessageLevel.Error); return(buildResult.Result.ExitCode); } // Invoke the dependency command var projectFilePath = projectPath.EndsWith("project.json") ? projectPath : Path.Combine(projectPath, "project.json"); var projectDirectory = Directory.GetParent(projectFilePath).FullName; var dependencyArgs = ToolCommandLineHelper.GetProjectDependencyCommandArgs( args, frameworkToUse.GetShortFolderName()); var exitCode = DotnetToolDispatcher.CreateDispatchCommand( dependencyArgs, frameworkToUse, configuration, null, buildBasePath, projectDirectory) .ForwardStdErr() .ForwardStdOut() .Execute() .ExitCode; return(exitCode); }
private int Build(ILogger logger, string projectPath, string configuration, NuGetFramework frameworkToUse, string buildBasePath) { logger.LogMessage(Resources.BuildingProject); var buildResult = DotNetBuildCommandHelper.Build( projectPath, configuration, frameworkToUse, buildBasePath); if (buildResult.Result.ExitCode != 0) { //Build failed. // Stop the process here. logger.LogMessage(Resources.BuildFailed); logger.LogMessage(string.Join(Environment.NewLine, buildResult.StdOut), LogMessageLevel.Error); logger.LogMessage(string.Join(Environment.NewLine, buildResult.StdErr), LogMessageLevel.Error); } return(buildResult.Result.ExitCode); }