private static async Task <RestoreSummary> ExecuteAndCommitAsync(RestoreSummaryRequest summaryRequest, IRestoreProgressReporter progressReporter, CancellationToken token) { RestoreResultPair result = await ExecuteAsync(summaryRequest, token); bool isNoOp = result.Result is NoOpRestoreResult; IReadOnlyList <string> filesToBeUpdated = isNoOp ? null : GetFilesToBeUpdated(result); RestoreSummary summary = null; try { if (!isNoOp) { progressReporter?.StartProjectUpdate(summaryRequest.Request.Project.FilePath, filesToBeUpdated); } summary = await CommitAsync(result, token); } finally { if (!isNoOp) { progressReporter?.EndProjectUpdate(summaryRequest.Request.Project.FilePath, filesToBeUpdated); } } return(summary);
static IReadOnlyList <string> GetFilesToBeUpdated(RestoreResultPair result) { List <string> filesToBeUpdated = new(3); // We know that we have 3 files. filesToBeUpdated.Add(result.Result.LockFilePath); foreach (MSBuildOutputFile msbuildOutputFile in result.Result.MSBuildOutputFiles) { filesToBeUpdated.Add(msbuildOutputFile.Path); } return(filesToBeUpdated.AsReadOnly()); }
public static async Task <RestoreSummary> CommitAsync(RestoreResultPair restoreResult, CancellationToken token) { var summaryRequest = restoreResult.SummaryRequest; var result = restoreResult.Result; var log = summaryRequest.Request.Log; // Commit the result log.LogInformation(Strings.Log_Committing); await result.CommitAsync(log, token); if (result.Success) { // For no-op results, don't log a minimal message since a summary is logged at the end // For regular results, log a minimal message so that users can see which projects were actually restored log.Log( result is NoOpRestoreResult ? LogLevel.Information : LogLevel.Minimal, string.Format( CultureInfo.CurrentCulture, summaryRequest.Request.ProjectStyle == ProjectStyle.DotnetToolReference ? Strings.Log_RestoreCompleteDotnetTool : Strings.Log_RestoreComplete, summaryRequest.InputPath, DatetimeUtility.ToReadableTimeFormat(result.ElapsedTime))); } else { log.LogMinimal(string.Format( CultureInfo.CurrentCulture, summaryRequest.Request.ProjectStyle == ProjectStyle.DotnetToolReference ? Strings.Log_RestoreFailedDotnetTool : Strings.Log_RestoreFailed, summaryRequest.InputPath, DatetimeUtility.ToReadableTimeFormat(result.ElapsedTime))); } // Remote the summary messages from the assets file. This will be removed later. var messages = restoreResult.Result.LockFile?.LogMessages .Select(e => new RestoreLogMessage(e.Level, e.Code, e.Message)) ?? Enumerable.Empty <RestoreLogMessage>(); // Build the summary return(new RestoreSummary( result, summaryRequest.InputPath, summaryRequest.ConfigFiles, summaryRequest.Sources, messages)); }
public static async Task <RestoreSummary> CommitAsync(RestoreResultPair restoreResult, CancellationToken token) { var summaryRequest = restoreResult.SummaryRequest; var result = restoreResult.Result; var log = summaryRequest.Request.Log; // Commit the result log.LogInformation(Strings.Log_Committing); await result.CommitAsync(log, token); if (result.Success) { log.LogMinimal(string.Format( CultureInfo.CurrentCulture, summaryRequest.Request.ProjectStyle == ProjectStyle.DotnetToolReference ? Strings.Log_RestoreCompleteDotnetTool : Strings.Log_RestoreComplete, DatetimeUtility.ToReadableTimeFormat(result.ElapsedTime), summaryRequest.InputPath)); } else { log.LogMinimal(string.Format( CultureInfo.CurrentCulture, summaryRequest.Request.ProjectStyle == ProjectStyle.DotnetToolReference ? Strings.Log_RestoreFailedDotnetTool : Strings.Log_RestoreFailed, DatetimeUtility.ToReadableTimeFormat(result.ElapsedTime), summaryRequest.InputPath)); } // Remote the summary messages from the assets file. This will be removed later. var messages = restoreResult.Result.LockFile?.LogMessages .Select(e => new RestoreLogMessage(e.Level, e.Code, e.Message)) ?? Enumerable.Empty <RestoreLogMessage>(); // Build the summary return(new RestoreSummary( result, summaryRequest.InputPath, summaryRequest.ConfigFiles, summaryRequest.Sources, messages)); }
public static async Task <RestoreSummary> CommitAsync(RestoreResultPair restoreResult, CancellationToken token) { var summaryRequest = restoreResult.SummaryRequest; var result = restoreResult.Result; var log = summaryRequest.Request.Log; // Commit the result log.LogInformation(Strings.Log_Committing); await result.CommitAsync(log, token); if (result.Success) { log.LogMinimal(string.Format( CultureInfo.CurrentCulture, Strings.Log_RestoreComplete, DatetimeUtility.ToReadableTimeFormat(result.ElapsedTime), summaryRequest.InputPath)); } else { log.LogMinimal(string.Format( CultureInfo.CurrentCulture, Strings.Log_RestoreFailed, DatetimeUtility.ToReadableTimeFormat(result.ElapsedTime), summaryRequest.InputPath)); } // Build the summary return(new RestoreSummary( result, summaryRequest.InputPath, summaryRequest.Settings, summaryRequest.Sources, summaryRequest.CollectorLogger.Errors)); }