Example #1
0
        public override Task ExecuteCommandAsync()
        {
            // On mono, parallel builds are broken for some reason. See https://gist.github.com/4201936 for the errors
            // That are thrown.
            DisableParallelProcessing |= RuntimeEnvironmentHelper.IsMono;

            if (DisableParallelProcessing)
            {
                HttpSourceResourceProvider.Throttle = SemaphoreSlimThrottle.CreateBinarySemaphore();
            }

            _CalculateEffectivePackageSaveModeInfo.Invoke(this, null);
            _CalculateEffectiveSettingsInfo.Invoke(this, null);
            var installPath = (string)_ResolveInstallPathInfo.Invoke(this, null);

            var configFilePath = Path.GetFullPath(Arguments.Count == 0 ? Constants.PackageReferenceFile : Arguments[0]);
            var configFileName = Path.GetFileName(configFilePath);

            // If the first argument is a packages.xxx.config file, install everything it lists
            // Otherwise, treat the first argument as a package Id
            if (CommandLineUtility.IsValidConfigFileName(configFileName))
            {
                Prerelease = true;

                // display opt-out message if needed
                if (Console != null && RequireConsent &&
                    new NuGet.PackageManagement.PackageRestoreConsent(Settings).IsGranted)
                {
                    var message = string.Format(
                        CultureInfo.CurrentCulture,
                        Local.RestoreCommandPackageRestoreOptOutMessage,
                        NuGetResources.PackageRestoreConsentCheckBoxText.Replace("&", ""));
                    Console.WriteLine(message);
                }

                return(PerformV2RestoreAsync(configFilePath, installPath));
            }
            else
            {
                throw new NotImplementedException();
            }
        }