private void PackageRestore(ProjectPackageReferenceFile projectPackageReferenceFile)
        {
            if (HasCanceled())
            {
                return;
            }

            var repoSettings = ServiceLocator.GetInstance <IRepositorySettings>();
            var fileSystem   = new PhysicalFileSystem(repoSettings.RepositoryPath);
            var projectName  = projectPackageReferenceFile.Project.GetName();

            try
            {
                WriteLine(VerbosityLevel.Normal, Resources.RestoringPackagesForProject, projectName);
                WriteLine(VerbosityLevel.Detailed, Resources.RestoringPackagesListedInFile,
                          projectPackageReferenceFile.FullPath);
                RestorePackages(projectPackageReferenceFile.FullPath, fileSystem);
            }
            catch (Exception ex)
            {
                var exceptionMessage = _msBuildOutputVerbosity >= (int)VerbosityLevel.Detailed ?
                                       ex.ToString() :
                                       ex.Message;
                var message = String.Format(
                    CultureInfo.CurrentCulture,
                    Resources.PackageRestoreFailedForProject, projectName,
                    exceptionMessage);
                WriteLine(VerbosityLevel.Quiet, message);
                ActivityLog.LogError(LogEntrySource, message);
                VsUtility.ShowError(_errorListProvider, TaskErrorCategory.Error,
                                    TaskPriority.High, message, hierarchyItem: null);
                _hasError = true;
            }
            finally
            {
                WriteLine(VerbosityLevel.Normal, Resources.PackageRestoreFinishedForProject, projectName);
            }
        }
예제 #2
0
        private void PackageRestore(ProjectPackageReferenceFile projectPackageReferenceFile)
        {
            if (HasCanceled())
            {
                return;
            }

            var repoSettings = ServiceLocator.GetInstance<IRepositorySettings>();
            var fileSystem = new PhysicalFileSystem(repoSettings.RepositoryPath);
            var projectName = projectPackageReferenceFile.Project.GetName();

            try
            {
                WriteLine(VerbosityLevel.Normal, Resources.RestoringPackagesForProject, projectName);            
                WriteLine(VerbosityLevel.Detailed, Resources.RestoringPackagesListedInFile, 
                    projectPackageReferenceFile.FullPath);
                RestorePackages(projectPackageReferenceFile.FullPath, fileSystem);
            }
            catch (Exception ex)
            {
                var exceptionMessage = _msBuildOutputVerbosity >= (int)VerbosityLevel.Detailed ?
                    ex.ToString() :
                    ex.Message;
                var message = String.Format(
                    CultureInfo.CurrentCulture, 
                    Resources.PackageRestoreFailedForProject, projectName, 
                    exceptionMessage);
                WriteLine(VerbosityLevel.Quiet, message);
                ActivityLog.LogError(LogEntrySource, message);
                VsUtility.ShowError(_errorListProvider, TaskErrorCategory.Error, 
                    TaskPriority.High, message, hierarchyItem: null);
                _hasError = true;
            }
            finally
            {
                WriteLine(VerbosityLevel.Normal, Resources.PackageRestoreFinishedForProject, projectName);
            }
        }