diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs index 88947e6416..6ea54e4372 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs @@ -180,6 +180,10 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon configuration.Features.UsePackageRepositoryOptimizations = false; } }) + .Add("pin|pinpackage|pin-package", + "Pin Package - Add a pin to the package after install. Available in 0.11.12+", + option => configuration.PinPackage = option != null + ) ; //todo: package name can be a url / installertype diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs index d624a49d98..4e563269de 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs @@ -220,6 +220,10 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon configuration.Features.UsePackageRepositoryOptimizations = false; } }) + .Add("pin|pinpackage|pin-package", + "Pin Package - Add a pin to the package after upgrade. Available in 0.11.12+", + option => configuration.PinPackage = option != null + ) ; } diff --git a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs index d3c3e51886..f14f7b3213 100644 --- a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs +++ b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs @@ -222,6 +222,7 @@ private void append_output(StringBuilder propertyValues, string append) public string DownloadChecksum64 { get; set; } public string DownloadChecksumType { get; set; } public string DownloadChecksumType64 { get; set; } + public bool PinPackage { get; set; } /// /// Configuration values provided by choco. diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs index 7f2763c6c2..6e02287412 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs @@ -401,6 +401,7 @@ public virtual void handle_package_result(PackageResult packageResult, Chocolate handle_extension_packages(config, packageResult); handle_template_packages(config, packageResult); pkgInfo.Arguments = capture_arguments(config, packageResult); + pkgInfo.IsPinned = config.PinPackage; } var toolsLocation = Environment.GetEnvironmentVariable(ApplicationParameters.Environment.ChocolateyToolsLocation);