From 851193882aa0dd79100192193eacb1cdf946898b Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH Date: Fri, 10 Dec 2021 18:24:58 -0600 Subject: [PATCH] (#886) Add packages.config elements for more global arguments This some more arguments in the global OptionSet as elements to the packages.config xml serialization schema. This is useful for users wanting arguments that were previously not available. It is also a pre-requisite for exporting remembered arguments, as some of the remembered arguments were not available in the previous available schema. --- .../PackagesConfigFilePackageSetting.cs | 20 +++++++++++++++++++ .../services/ChocolateyPackageService.cs | 11 ++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/chocolatey/infrastructure.app/configuration/PackagesConfigFilePackageSetting.cs b/src/chocolatey/infrastructure.app/configuration/PackagesConfigFilePackageSetting.cs index 25a0e929a5..1a1dc48aa3 100644 --- a/src/chocolatey/infrastructure.app/configuration/PackagesConfigFilePackageSetting.cs +++ b/src/chocolatey/infrastructure.app/configuration/PackagesConfigFilePackageSetting.cs @@ -138,5 +138,25 @@ public sealed class PackagesConfigFilePackageSetting [XmlAttribute(AttributeName = "disableRepositoryOptimizations")] public bool DisableRepositoryOptimizations { get; set; } + [XmlAttribute(AttributeName = "acceptLicense")] + public bool AcceptLicense { get; set; } + + [XmlAttribute(AttributeName = "confirm")] + public bool Confirm { get; set; } + + [XmlAttribute(AttributeName = "limitOutput")] + public bool LimitOutput { get; set; } + + [XmlAttribute(AttributeName = "cacheLocation")] + public string CacheLocation { get; set; } + + [XmlAttribute(AttributeName = "failOnStderr")] + public bool FailOnStderr { get; set; } + + [XmlAttribute(AttributeName = "useSystemPowershell")] + public bool UseSystemPowershell { get; set; } + + [XmlAttribute(AttributeName = "noProgress")] + public bool NoProgress { get; set; } } } diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs index 84f1e51d9b..50c2be4ec1 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs @@ -766,6 +766,17 @@ private IEnumerable get_packages_from_config(string pac if (pkgSettings.ExitWhenRebootDetected) packageConfig.Features.ExitOnRebootDetected = true; if (pkgSettings.IgnoreDetectedReboot) packageConfig.Features.ExitOnRebootDetected = false; if (pkgSettings.DisableRepositoryOptimizations) packageConfig.Features.UsePackageRepositoryOptimizations = false; + if (pkgSettings.AcceptLicense) packageConfig.AcceptLicense = true; + if (pkgSettings.Confirm) + { + packageConfig.PromptForConfirmation = false; + packageConfig.AcceptLicense = true; + } + if (pkgSettings.LimitOutput) packageConfig.RegularOutput = false; + packageConfig.CacheLocation = string.IsNullOrWhiteSpace(pkgSettings.CacheLocation) ? packageConfig.CacheLocation : pkgSettings.CacheLocation; + if (pkgSettings.FailOnStderr) packageConfig.Features.FailOnStandardError = true; + if (pkgSettings.UseSystemPowershell) packageConfig.Features.UsePowerShellHost = false; + if (pkgSettings.NoProgress) packageConfig.Features.ShowDownloadProgress = false; this.Log().Info(ChocolateyLoggers.Important, @"{0}".format_with(packageConfig.PackageNames)); packageConfigs.Add(packageConfig);