Example #1
0
 private static void LogHelperMessageForPathTooLongException(Console logger)
 {
     if (!IsWindows10(logger))
     {
         logger.WriteWarning(LocalizedResourceManager.GetString(nameof(NuGetResources.Warning_LongPath_UnsupportedOS)));
     }
     else if (!IsSupportLongPathEnabled(logger))
     {
         logger.WriteWarning(LocalizedResourceManager.GetString(nameof(NuGetResources.Warning_LongPath_DisabledPolicy)));
     }
     else if (!IsRuntimeGreaterThanNet462(logger))
     {
         logger.WriteWarning(LocalizedResourceManager.GetString(nameof(NuGetResources.Warning_LongPath_UnsupportedNetFramework)));
     }
 }
Example #2
0
        public async override Task ExecuteCommandAsync()
        {
            if (Verbose)
            {
                Console.WriteWarning(LocalizedResourceManager.GetString("Option_VerboseDeprecated"));
                Verbosity = Verbosity.Detailed;
            }

            var listCommandRunner = new ListCommandRunner();
            var listEndpoints     = GetEndpointsAsync();

            var list = new ListArgs(Arguments,
                                    listEndpoints,
                                    Settings,
                                    Console,
                                    Console.PrintJustified,
                                    Verbosity == Verbosity.Detailed,
                                    LocalizedResourceManager.GetString("ListCommandNoPackages"),
                                    LocalizedResourceManager.GetString("ListCommand_LicenseUrl"),
                                    LocalizedResourceManager.GetString("ListCommand_ListNotSupported"),
                                    AllVersions,
                                    IncludeDelisted,
                                    Prerelease,
                                    CancellationToken.None);

            await listCommandRunner.ExecuteCommand(list);
        }
Example #3
0
        public override async Task ExecuteCommandAsync()
        {
            if (NoPrompt)
            {
                Console.WriteWarning(LocalizedResourceManager.GetString("Warning_NoPromptDeprecated"));
                NonInteractive = true;
            }

            string packageId      = Arguments[0];
            string packageVersion = Arguments[1];
            string apiKeyValue    = null;

            if (Arguments.Count > 2)
            {
                apiKeyValue = Arguments[2];
            }

            await DeleteRunner.Run(
                Settings,
                SourceProvider,
                packageId,
                packageVersion,
                Source,
                apiKeyValue,
                NonInteractive,
                Console.Confirm,
                Console);
        }
Example #4
0
        private async Task UpdateAllPackages(string solutionDir, INuGetProjectContext projectContext)
        {
            Console.WriteLine(LocalizedResourceManager.GetString("ScanningForProjects"));

            // Search recursively for all packages.xxx.config files
            string[] packagesConfigFiles = Directory.GetFiles(
                solutionDir, "*.config", SearchOption.AllDirectories);

            var projects = packagesConfigFiles.Where(s => Path.GetFileName(s).StartsWith("packages.", StringComparison.OrdinalIgnoreCase))
                           .Select(s => GetProject(s, projectContext))
                           .Where(p => p != null)
                           .Distinct()
                           .ToList();

            if (projects.Count == 0)
            {
                Console.WriteLine(LocalizedResourceManager.GetString("NoProjectsFound"));
                return;
            }

            if (projects.Count == 1)
            {
                Console.WriteLine(LocalizedResourceManager.GetString("FoundProject"), projects.Single().ProjectName);
            }
            else
            {
                Console.WriteLine(LocalizedResourceManager.GetString("FoundProjects"), projects.Count, String.Join(", ", projects.Select(p => p.ProjectName)));
            }

            string repositoryPath = GetRepositoryPathFromSolution(solutionDir);

            foreach (var project in projects)
            {
                try
                {
                    await UpdatePackagesAsync(project, repositoryPath);

                    if (Verbose)
                    {
                        Console.WriteLine();
                    }
                }
                catch (Exception e)
                {
                    if (Console.Verbosity == Verbosity.Detailed || ExceptionLogger.Instance.ShowStack)
                    {
                        Console.WriteWarning(e.ToString());
                    }
                    else
                    {
                        Console.WriteWarning(ExceptionUtilities.DisplayMessage(e));
                    }
                }
            }
        }
Example #5
0
        private MSBuildProjectSystem GetProject(string path, INuGetProjectContext projectContext)
        {
            try
            {
                return(GetMSBuildProject(path, projectContext));
            }
            catch (CommandLineException e)
            {
                if (Console.Verbosity == Verbosity.Detailed || ExceptionLogger.Instance.ShowStack)
                {
                    Console.WriteWarning(e.ToString());
                }
                else
                {
                    Console.WriteWarning(ExceptionUtilities.DisplayMessage(e));
                }
            }

            return(null);
        }