public async override Task ExecuteCommand()
        {
            CalculateEffectivePackageSaveMode();
            DetermineRestoreMode();
            if (_restoringForSolution && !String.IsNullOrEmpty(SolutionDirectory))
            {
                // option -SolutionDirectory is not valid when we are restoring packages for a solution
                throw new InvalidOperationException(LocalizedResourceManager.GetString("RestoreCommandOptionSolutionDirectoryIsInvalid"));
            }

            string packagesFolderPath       = GetPackagesFolderPath();
            var    packageSourceProvider    = new NuGet.Configuration.PackageSourceProvider(Settings);
            var    sourceRepositoryProvider = new SourceRepositoryProvider(packageSourceProvider, ResourceProviders);
            var    nuGetPackageManager      = new NuGetPackageManager(sourceRepositoryProvider, packagesFolderPath);
            HashSet <PackageReference> installedPackageReferences;
            Stopwatch watch = new Stopwatch();

            if (_restoringForSolution)
            {
                watch.Restart();
                installedPackageReferences = GetInstalledPackageReferencesFromSolutionFile(_solutionFileFullPath);
                watch.Stop();
                DisplayExecutedTime(watch.Elapsed, "GetInstalledPackageReferencesFromSolution");
            }
            else
            {
                // By default the PackageReferenceFile does not throw if the file does not exist at the specified path.
                // So we'll need to verify that the file exists.
                if (!File.Exists(_packagesConfigFileFullPath))
                {
                    string message = String.Format(CultureInfo.CurrentCulture, LocalizedResourceManager.GetString("RestoreCommandFileNotFound"), _packagesConfigFileFullPath);
                    throw new InvalidOperationException(message);
                }

                watch.Restart();
                installedPackageReferences = GetInstalledPackageReferences(_packagesConfigFileFullPath);
                watch.Stop();
                DisplayExecutedTime(watch.Elapsed, "GetInstalledPackageReferences");
            }

            watch.Restart();
            var missingPackages = PackageRestoreManager.GetMissingPackages(nuGetPackageManager, installedPackageReferences);

            watch.Stop();
            DisplayExecutedTime(watch.Elapsed, "GetMissingPackages");

            watch.Restart();
            // If sourceRepositories parameter below is null, then the sourceRepositories from the SourceRepositoryProvider in NuGetPackageManager will be used
            await PackageRestoreManager.RestoreMissingPackages(nuGetPackageManager, missingPackages, Console, CancellationToken.None,
                                                               packageRestoredEvent : null, sourceRepositories : GetSourceRepositoriesFromSourceSwitch(sourceRepositoryProvider));

            watch.Stop();
            DisplayExecutedTime(watch.Elapsed, "RestorePackages");
        }