Skip to content

Commit

Permalink
(#886) Add packages.config elements for remaining install arguments
Browse files Browse the repository at this point in the history
This adds the remaining arguments in the install command's 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.
  • Loading branch information
TheCakeIsNaOH committed Mar 21, 2022
1 parent 726ea0f commit 90148fc
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,78 @@ 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; }

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,34 @@ 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.Timeout == -1 ? packageConfig.CommandExecutionTimeoutSeconds : pkgSettings.Timeout;
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;

this.Log().Info(ChocolateyLoggers.Important, @"{0}".format_with(packageConfig.PackageNames));
packageConfigs.Add(packageConfig);
Expand Down

0 comments on commit 90148fc

Please sign in to comment.