private string CreateInstallCommand(ChocolateyPackageVersion package)
        {
            const string installCommandTemplate = @"cinst '{0}' -version '{1}'";

            var installCommand = string.Format(installCommandTemplate, package.Id, package.Version);

            return installCommand;
        }
Ejemplo n.º 2
0
        public async Task Update(ChocolateyPackageVersion package)
        {
            using (var powershell = PowerShell.Create())
            {
                var command = string.Format("cup {0}", package.Id);

                powershell.AddScript(command);
                powershell.Streams.Error.DataAdded += ErrorDataAdded;
                powershell.Streams.Warning.DataAdded += WarningDataAdded;

                var outputCollection = new PSDataCollection<PSObject>();
                outputCollection.DataAdded += this.SendOutput;
                
                await Task.Factory.StartNew(() => powershell.Invoke(null, outputCollection, null));
            }
        }
Ejemplo n.º 3
0
        public async Task Uninstall(ChocolateyPackageVersion package)
        {
            using (var powershell = PowerShell.Create())
            {
                var command = string.Format(
                    "cuninst {0} -version {1}",
                    package.Id,
                    package.Version);

                powershell.AddScript(command);

                var outputCollection = new PSDataCollection<PSObject>();
                outputCollection.DataAdded += this.SendOutput;

                await Task.Factory.StartNew(() => powershell.Invoke(null, outputCollection, null));
            }
        }
Ejemplo n.º 4
0
        public async Task Install(ChocolateyPackageVersion package, string arguments, CancellationToken cancellationToken)
        {
            var args = string.IsNullOrEmpty(arguments) ? string.Empty : " -installArguments " + arguments;

            using (var powershell = PowerShell.Create())
            {
                var command = string.Format(
                    "cinst {0} -version {1}{2}",
                    package.Id,
                    package.Version,
                    args);

                powershell.AddScript(command);

                var outputCollection = new PSDataCollection<PSObject>();
                outputCollection.DataAdded += this.SendOutput;

                await Task.Factory.StartNew(() => powershell.Invoke(null, outputCollection, null), cancellationToken);
            }
        }
Ejemplo n.º 5
0
 public async Task Install(ChocolateyPackageVersion package)
 {
     await this.Install(package, string.Empty);
 }
Ejemplo n.º 6
0
 public async Task Install(ChocolateyPackageVersion package, string arguments)
 {
     await this.Install(package, string.Empty, new CancellationToken());
 }
        public void RemovePackageToInstallList(ChocolateyPackageVersion package)
        {
            this.Packages.Remove(package);

            this.ClearInstallListCommand.RaiseCanExecuteChanged();
            this.InstallPackagesCommand.RaiseCanExecuteChanged();
            this.SaveSetupScriptCommand.RaiseCanExecuteChanged();
        }
Ejemplo n.º 8
0
        private static ChocolateyPackageVersion ConvertToPackageVersion(FeedPackage package)
        {
            var convertedPackage = new ChocolateyPackageVersion
            {
                Author = package.Authors,
                ChocolateyLink = new Uri(package.GalleryDetailsUrl),
                Id = package.Id,
                Title = package.Title,
                Description = package.Description,
                Version = package.Version,
                ReleaseNotes = package.ReleaseNotes,
                DownloadCount = package.DownloadCount,
                IconLink = string.IsNullOrEmpty(package.IconUrl)
                        ? null
                        : new Uri(package.IconUrl),
                ProjectLink =
                    string.IsNullOrEmpty(package.ProjectUrl)
                        ? null
                        : new Uri(package.ProjectUrl)
            };

            return convertedPackage;
        }
        private async Task InstallPackage(ChocolateyPackageVersion package)
        {
            this.IsWorking = true;
            this.StatusMessage = "Installing";
            
            if (string.IsNullOrEmpty(this.InstallArguments))
            {
                this._consoleViewModel.AddConsoleLine(
                    "Installing package {0} from {1}",
                    package.Id,
                    this._feed.Source.Location);
            }
            else
            {
                this._consoleViewModel.AddConsoleLine(
                    "Installing package {0} from {1} with arguments {2}",
                    package.Id,
                    this._feed.Source.Location,
                    this.InstallArguments);
            }

            try
            {
                this._installer.OutputReceived += OutputReceived;

                if(string.IsNullOrEmpty(this.InstallArguments))
                {
                    await this._installer.Install(package);
                }
                else
                {
                    await this._installer.Install(package, this.InstallArguments);
                }

                this._installer.OutputReceived -= OutputReceived;
            }
            catch (Exception ex)
            {
                this._consoleViewModel.AddConsoleLine(
                    "Failed to install package {0} from {1}",
                    package.Id,
                    this._feed.Source.Location);
                this._consoleViewModel.AddConsoleLine(ex.Message);
            }

            this.IsWorking = false;
            this.CanSelectPackage = true;
            this.StatusMessage = "Ready";

            await this._installedPackagesViewModel.RefreshPackages();
        }
        private async Task UpdatePackage(ChocolateyPackageVersion package)
        {
            this.IsWorking = true;
            this.StatusMessage = string.Format("Updating {0}", package.Id);

            this._installer.OutputReceived += this.OutputReceived;

            await this._installer.Update(package);

            this._installer.OutputReceived -= this.OutputReceived;
            
            await this.RefreshPackages();

            this.StatusMessage = "Ready";
            this.IsWorking = false;
        }