Пример #1
0
        static void DownloadPackages(SlnxHandler slnx, bool quite, bool autoUpdateDependencies)
        {
            _logger.Info("Downloading required NuGet packages...");
            var frameworks        = slnx.Projects.Select(p => NuGetFramework.ParseFolder(p.Framework));
            var reducedFrameworks = new FrameworkReducer().ReduceUpwards(frameworks);

            if (reducedFrameworks.Count() != 1)
            {
                throw new Exceptions.MultiFrameworkAppException($"It has not been possible to find a single common framework among the C# project specified in the SlnX file. Mixed .NET Framework and Core projects are not supported");
            }
            var requestedFramework = reducedFrameworks.First();

            slnx.Packages = PerformPackageDownloadProcess(slnx.PackagesInfo, requestedFramework, quite, autoUpdateDependencies, "Loading packages...");

            if (slnx.DebugSlnxItems.Count != 0)
            {
                _logger.Info("Downloading NuGet packages marked as debug...");
                _logger.Debug("Need to download the package to properly gather the Libraries list. The dependencies are ignored to avoid package versions issues.");

                foreach ((var packageInfo, var debugSlnx) in slnx.DebugSlnxItems)
                {
                    _logger.Debug("Evaluating {0}.", packageInfo);
                    var installedDebugPackage  = PerformPackageDownloadProcess(new[] { packageInfo }, requestedFramework, quite, false, $"Loading debug package {packageInfo} without dependencies...");
                    var installedNuGetPackages = PerformPackageDownloadProcess(debugSlnx.PackagesInfo, requestedFramework, quite, autoUpdateDependencies, $"Loading debug package {packageInfo} defined NuGet packages...");
                    debugSlnx.Packages = installedDebugPackage.Concat(installedNuGetPackages);
                    slnx.DebugPackages.Add(installedDebugPackage.First()); //Keep a reference to the debug package
                }
            }
        }