protected override void BeginProcessing()
        {
            // Create a repository story (the PSResourceRepository.xml file) if it does not already exist
            // This is to create a better experience for those who have just installed v3 and want to get up and running quickly
            RepositorySettings.CheckRepositoryStore();

            _installHelper = new InstallHelper(cmdletPassedIn: this);
        }
        protected override void ProcessRecord()
        {
            // Define the cancellation token.
            CancellationTokenSource source            = new CancellationTokenSource();
            CancellationToken       cancellationToken = source.Token;

            var installHelper = new InstallHelper(update: true, cancellationToken, this);

            installHelper.ProcessInstallParams(_name, _version, _prerelease, _repository, _scope, _acceptLicense, _quiet, _reinstall: false, _force: false, _trustRepository, _noClobber, _credential, _requiredResourceFile: null, _requiredResourceJson: null, _requiredResourceHash: null);
        }
        protected override void ProcessRecord()
        {
            // Define the cancellation token.
            CancellationTokenSource source            = new CancellationTokenSource();
            CancellationToken       cancellationToken = source.Token;

            var installHelper = new InstallHelper(updatePkg: false, savePkg: false, cancellationToken: cancellationToken, cmdletPassedIn: this);

            switch (ParameterSetName)
            {
            case NameParameterSet:
                installHelper.InstallPackages(
                    names: Name,
                    versionRange: _versionRange,
                    prerelease: Prerelease,
                    repository: Repository,
                    acceptLicense: AcceptLicense,
                    quiet: Quiet,
                    reinstall: Reinstall,
                    force: false,
                    trustRepository: TrustRepository,
                    noClobber: false,
                    credential: Credential,
                    requiredResourceFile: null,
                    requiredResourceJson: null,
                    requiredResourceHash: null,
                    specifiedPath: null,
                    asNupkg: false,
                    includeXML: true,
                    pathsToInstallPkg: _pathsToInstallPkg);
                break;

            case RequiredResourceFileParameterSet:
                ThrowTerminatingError(new ErrorRecord(
                                          new PSNotImplementedException("RequiredResourceFileParameterSet is not yet implemented. Please rerun cmdlet with other parameter set."),
                                          "CommandParameterSetNotImplementedYet",
                                          ErrorCategory.NotImplemented,
                                          this));
                break;

            case RequiredResourceParameterSet:
                ThrowTerminatingError(new ErrorRecord(
                                          new PSNotImplementedException("RequiredResourceParameterSet is not yet implemented. Please rerun cmdlet with other parameter set."),
                                          "CommandParameterSetNotImplementedYet",
                                          ErrorCategory.NotImplemented,
                                          this));
                break;

            default:
                Dbg.Assert(false, "Invalid parameter set");
                break;
            }
        }
        protected override void ProcessRecord()
        {
            // Define the cancellation token.
            CancellationTokenSource source            = new CancellationTokenSource();
            CancellationToken       cancellationToken = source.Token;

            // If PSModuleInfo object
            if (_inputObject != null && _inputObject[0].GetType().Name.Equals("PSModuleInfo"))
            {
                foreach (PSModuleInfo pkg in _inputObject)
                {
                    var installHelp = new InstallHelper(update: false, cancellationToken, this);
                    var prerelease  = false;

                    if (pkg.PrivateData != null)
                    {
                        Hashtable privateData = (Hashtable)pkg.PrivateData;
                        if (privateData.ContainsKey("PSData"))
                        {
                            Hashtable psData = (Hashtable)privateData["PSData"];

                            if (psData.ContainsKey("Prerelease") && !string.IsNullOrEmpty((string)psData["Prerelease"]))
                            {
                                prerelease = true;
                            }
                        }
                    }

                    installHelp.ProcessInstallParams(new[] { pkg.Name }, pkg.Version.ToString(), prerelease, _repository, _scope, _acceptLicense, _quiet, _reinstall, _force: false, _trustRepository, _noClobber, _credential, _requiredResourceFile, _requiredResourceJson, _requiredResourceHash);
                }
            }
            else if (_inputObject != null && _inputObject[0].GetType().Name.Equals("PSObject"))
            {
                // If PSObject
                foreach (PSObject pkg in _inputObject)
                {
                    var installHelp = new InstallHelper(update: false, cancellationToken, this);

                    if (pkg != null)
                    {
                        var name       = (string)pkg.Properties["Name"].Value;
                        var version    = (NuGetVersion)pkg.Properties["Version"].Value;
                        var prerelease = version.IsPrerelease;

                        installHelp.ProcessInstallParams(new[] { name }, version.ToString(), prerelease, _repository, _scope, _acceptLicense, _quiet, _reinstall, _force: false, _trustRepository, _noClobber, _credential, _requiredResourceFile, _requiredResourceJson, _requiredResourceHash);
                    }
                }
            }

            var installHelper = new InstallHelper(update: false, cancellationToken, this);

            installHelper.ProcessInstallParams(_name, _version, _prerelease, _repository, _scope, _acceptLicense, _quiet, _reinstall, _force: false, _trustRepository, _noClobber, _credential, _requiredResourceFile, _requiredResourceJson, _requiredResourceHash);
        }
Exemple #5
0
        protected override void BeginProcessing()
        {
            // Create a repository story (the PSResourceRepository.xml file) if it does not already exist
            // This is to create a better experience for those who have just installed v3 and want to get up and running quickly
            RepositorySettings.CheckRepositoryStore();

            // If the user does not specify a path to save to, use the user's current working directory
            if (string.IsNullOrWhiteSpace(_path))
            {
                _path = SessionState.Path.CurrentLocation.Path;
            }

            _installHelper = new InstallHelper(cmdletPassedIn: this);
        }
        protected override void BeginProcessing()
        {
            // Create a repository story (the PSResourceRepository.xml file) if it does not already exist
            // This is to create a better experience for those who have just installed v3 and want to get up and running quickly
            RepositorySettings.CheckRepositoryStore();

            _pathsToInstallPkg = Utils.GetAllInstallationPaths(this, Scope);

            _cancellationTokenSource = new CancellationTokenSource();
            _findHelper = new FindHelper(
                cancellationToken: _cancellationTokenSource.Token,
                cmdletPassedIn: this);

            _installHelper = new InstallHelper(cmdletPassedIn: this);
        }
Exemple #7
0
        protected override void ProcessRecord()
        {
            // Define the cancellation token.
            CancellationTokenSource source            = new CancellationTokenSource();
            CancellationToken       cancellationToken = source.Token;

            var installHelper = new InstallHelper(updatePkg: false, savePkg: true, cancellationToken: cancellationToken, cmdletPassedIn: this);

            switch (ParameterSetName)
            {
            case NameParameterSet:
                installHelper.InstallPackages(
                    names: Name,
                    versionRange: _versionRange,
                    prerelease: Prerelease,
                    repository: Repository,
                    acceptLicense: true,
                    quiet: true,
                    reinstall: true,
                    force: false,
                    trustRepository: TrustRepository,
                    noClobber: false,
                    credential: Credential,
                    requiredResourceFile: null,
                    requiredResourceJson: null,
                    requiredResourceHash: null,
                    specifiedPath: _path,
                    asNupkg: false,
                    includeXML: false,
                    pathsToInstallPkg: new List <string> {
                    _path
                });
                break;

            default:
                Dbg.Assert(false, "Invalid parameter set");
                break;
            }
        }