Example #1
0
 void ReportRestoreError(RestoreResult restoreResult)
 {
     foreach (LibraryRange libraryRange in restoreResult.GetAllUnresolved())
     {
         packageManagementEvents.OnPackageOperationMessageLogged(
             MessageLevel.Info,
             GettextCatalog.GetString("Restore failed for '{0}'."),
             libraryRange.ToString());
     }
     throw new ApplicationException(GettextCatalog.GetString("Restore failed."));
 }
        private async Task BuildIntegratedProjectReportErrorAsync(string projectName,
                                                                  RestoreResult restoreResult,
                                                                  CancellationToken token)
        {
            Debug.Assert(!restoreResult.Success);

            if (token.IsCancellationRequested)
            {
                // If an operation is canceled, a single message gets shown in the summary
                // that package restore has been canceled. Do not report it as separate errors
                _canceled = true;
                return;
            }

            // HasErrors will be used to show a message in the output window, that, Package restore failed
            // If Canceled is not already set to true
            _hasErrors = true;

            // Switch to main thread to update the error list window or output window
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            foreach (var libraryRange in restoreResult.GetAllUnresolved())
            {
                var message = string.Format(CultureInfo.CurrentCulture,
                                            Resources.BuildIntegratedPackageRestoreFailedForProject,
                                            projectName,
                                            libraryRange.ToString());

                WriteLine(VerbosityLevel.Quiet, message);

                MessageHelper.ShowError(_errorListProvider,
                                        TaskErrorCategory.Error,
                                        TaskPriority.High,
                                        message,
                                        hierarchyItem: null);
            }
        }