Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#886) Add support for more arguments in packages.config #2504

Merged
merged 1 commit into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,98 @@ public sealed class PackagesConfigFilePackageSetting

[XmlAttribute(AttributeName = "force")]
public bool Force { get; set; }

[XmlAttribute(AttributeName = "prerelease")]
public bool Prerelease { get; set; }

[XmlAttribute(AttributeName = "overrideArguments")]
public bool OverrideArguments { get; set; }

[XmlAttribute(AttributeName = "notSilent")]
public bool NotSilent { get; set; }

[XmlAttribute(AttributeName = "allowDowngrade")]
public bool AllowDowngrade { get; set; }

[XmlAttribute(AttributeName = "forceDependencies")]
public bool ForceDependencies { get; set; }

[XmlAttribute(AttributeName = "skipAutomationScripts")]
public bool SkipAutomationScripts { get; set; }

[XmlAttribute(AttributeName = "user")]
public string User { get; set; }

[XmlAttribute(AttributeName = "password")]
public string Password { get; set; }

[XmlAttribute(AttributeName = "cert")]
public string Cert { get; set; }

[XmlAttribute(AttributeName = "certPassword")]
public string CertPassword { get; set; }

[XmlAttribute(AttributeName = "ignoreChecksums")]
public bool IgnoreChecksums { get; set; }

[XmlAttribute(AttributeName = "allowEmptyChecksums")]
public bool AllowEmptyChecksums { get; set; }

[XmlAttribute(AttributeName = "allowEmptyChecksumsSecure")]
public bool AllowEmptyChecksumsSecure { get; set; }

[XmlAttribute(AttributeName = "requireChecksums")]
public bool RequireChecksums { get; set; }

[XmlAttribute(AttributeName = "downloadChecksum")]
public string DownloadChecksum { get; set; }

[XmlAttribute(AttributeName = "downloadChecksum64")]
public string DownloadChecksum64 { get; set; }

[XmlAttribute(AttributeName = "downloadChecksumType")]
public string DownloadChecksumType { get; set; }

[XmlAttribute(AttributeName = "downloadChecksumType64")]
public string DownloadChecksumType64 { get; set; }

[XmlAttribute(AttributeName = "ignorePackageExitCodes")]
public bool IgnorePackageExitCodes { get; set; }

[XmlAttribute(AttributeName = "usePackageExitCodes")]
public bool UsePackageExitCodes { get; set; }

[XmlAttribute(AttributeName = "stopOnFirstFailure")]
public bool StopOnFirstFailure { get; set; }

[XmlAttribute(AttributeName = "exitWhenRebootDetected")]
public bool ExitWhenRebootDetected { get; set; }

[XmlAttribute(AttributeName = "ignoreDetectedReboot")]
public bool IgnoreDetectedReboot { get; set; }

[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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,45 @@ private IEnumerable<ChocolateyConfiguration> get_packages_from_config(string pac
if (Enum.TryParse(pkgSettings.Source, true, out sourceType)) packageConfig.SourceType = sourceType;
if (pkgSettings.Force) packageConfig.Force = true;
packageConfig.CommandExecutionTimeoutSeconds = pkgSettings.CommandExecutionTimeoutSeconds == -1 ? packageConfig.CommandExecutionTimeoutSeconds : pkgSettings.CommandExecutionTimeoutSeconds;
if (pkgSettings.Prerelease) packageConfig.Prerelease = true;
if (pkgSettings.OverrideArguments) packageConfig.OverrideArguments = true;
if (pkgSettings.NotSilent) packageConfig.NotSilent = true;
if (pkgSettings.AllowDowngrade) packageConfig.AllowDowngrade = true;
if (pkgSettings.ForceDependencies) packageConfig.ForceDependencies = true;
if (pkgSettings.SkipAutomationScripts) packageConfig.SkipPackageInstallProvider = true;
packageConfig.SourceCommand.Username = string.IsNullOrWhiteSpace(pkgSettings.User) ? packageConfig.SourceCommand.Username : pkgSettings.User;
packageConfig.SourceCommand.Password = string.IsNullOrWhiteSpace(pkgSettings.Password) ? packageConfig.SourceCommand.Password : pkgSettings.Password;
packageConfig.SourceCommand.Certificate = string.IsNullOrWhiteSpace(pkgSettings.Cert) ? packageConfig.SourceCommand.Certificate : pkgSettings.Cert;
packageConfig.SourceCommand.CertificatePassword = string.IsNullOrWhiteSpace(pkgSettings.CertPassword) ? packageConfig.SourceCommand.CertificatePassword : pkgSettings.CertPassword;
if (pkgSettings.IgnoreChecksums) packageConfig.Features.ChecksumFiles = false;
if (pkgSettings.AllowEmptyChecksums) packageConfig.Features.AllowEmptyChecksums = true;
if (pkgSettings.AllowEmptyChecksumsSecure) packageConfig.Features.AllowEmptyChecksumsSecure = true;
if (pkgSettings.RequireChecksums)
{
packageConfig.Features.AllowEmptyChecksums = false;
packageConfig.Features.AllowEmptyChecksumsSecure = false;
}
packageConfig.DownloadChecksum = string.IsNullOrWhiteSpace(pkgSettings.DownloadChecksum) ? packageConfig.DownloadChecksum : pkgSettings.DownloadChecksum;
packageConfig.DownloadChecksum64 = string.IsNullOrWhiteSpace(pkgSettings.DownloadChecksum64) ? packageConfig.DownloadChecksum64 : pkgSettings.DownloadChecksum64;
packageConfig.DownloadChecksum = string.IsNullOrWhiteSpace(pkgSettings.DownloadChecksumType) ? packageConfig.DownloadChecksumType : pkgSettings.DownloadChecksumType;
packageConfig.DownloadChecksumType64 = string.IsNullOrWhiteSpace(pkgSettings.DownloadChecksumType64) ? packageConfig.DownloadChecksumType : pkgSettings.DownloadChecksumType64;
if (pkgSettings.IgnorePackageExitCodes) packageConfig.Features.UsePackageExitCodes = false;
if (pkgSettings.UsePackageExitCodes) packageConfig.Features.UsePackageExitCodes = true;
if (pkgSettings.StopOnFirstFailure) packageConfig.Features.StopOnFirstPackageFailure = true;
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);
Expand Down