Skip to content

Commit 6c72f03

Browse files
committed
(chocolatey#886) Add packages.config elements for remaining install arguments
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.
1 parent 46b657e commit 6c72f03

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed

src/chocolatey/infrastructure.app/configuration/PackagesConfigFilePackageSetting.cs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,78 @@ public sealed class PackagesConfigFilePackageSetting
6565

6666
[XmlAttribute(AttributeName = "force")]
6767
public bool Force { get; set; }
68+
69+
[XmlAttribute(AttributeName = "prerelease")]
70+
public bool Prerelease { get; set; }
71+
72+
[XmlAttribute(AttributeName = "overrideArguments")]
73+
public bool OverrideArguments { get; set; }
74+
75+
[XmlAttribute(AttributeName = "notSilent")]
76+
public bool NotSilent { get; set; }
77+
78+
[XmlAttribute(AttributeName = "allowDowngrade")]
79+
public bool AllowDowngrade { get; set; }
80+
81+
[XmlAttribute(AttributeName = "forceDependencies")]
82+
public bool ForceDependencies { get; set; }
83+
84+
[XmlAttribute(AttributeName = "skipAutomationScripts")]
85+
public bool SkipAutomationScripts { get; set; }
86+
87+
[XmlAttribute(AttributeName = "user")]
88+
public string User { get; set; }
89+
90+
[XmlAttribute(AttributeName = "password")]
91+
public string Password { get; set; }
92+
93+
[XmlAttribute(AttributeName = "cert")]
94+
public string Cert { get; set; }
95+
96+
[XmlAttribute(AttributeName = "certPassword")]
97+
public string CertPassword { get; set; }
98+
99+
[XmlAttribute(AttributeName = "ignoreChecksums")]
100+
public bool IgnoreChecksums { get; set; }
101+
102+
[XmlAttribute(AttributeName = "allowEmptyChecksums")]
103+
public bool AllowEmptyChecksums { get; set; }
104+
105+
[XmlAttribute(AttributeName = "allowEmptyChecksumsSecure")]
106+
public bool AllowEmptyChecksumsSecure { get; set; }
107+
108+
[XmlAttribute(AttributeName = "requireChecksums")]
109+
public bool RequireChecksums { get; set; }
110+
111+
[XmlAttribute(AttributeName = "downloadChecksum")]
112+
public string DownloadChecksum { get; set; }
113+
114+
[XmlAttribute(AttributeName = "downloadChecksum64")]
115+
public string DownloadChecksum64 { get; set; }
116+
117+
[XmlAttribute(AttributeName = "downloadChecksumType")]
118+
public string DownloadChecksumType { get; set; }
119+
120+
[XmlAttribute(AttributeName = "downloadChecksumType64")]
121+
public string DownloadChecksumType64 { get; set; }
122+
123+
[XmlAttribute(AttributeName = "ignorePackageExitCodes")]
124+
public bool IgnorePackageExitCodes { get; set; }
125+
126+
[XmlAttribute(AttributeName = "usePackageExitCodes")]
127+
public bool UsePackageExitCodes { get; set; }
128+
129+
[XmlAttribute(AttributeName = "stopOnFirstFailure")]
130+
public bool StopOnFirstFailure { get; set; }
131+
132+
[XmlAttribute(AttributeName = "exitWhenRebootDetected")]
133+
public bool ExitWhenRebootDetected { get; set; }
134+
135+
[XmlAttribute(AttributeName = "ignoreDetectedReboot")]
136+
public bool IgnoreDetectedReboot { get; set; }
137+
138+
[XmlAttribute(AttributeName = "disableRepositoryOptimizations")]
139+
public bool DisableRepositoryOptimizations { get; set; }
140+
68141
}
69142
}

src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,34 @@ private IEnumerable<ChocolateyConfiguration> get_packages_from_config(string pac
739739
if (Enum.TryParse(pkgSettings.Source, true, out sourceType)) packageConfig.SourceType = sourceType;
740740
if (pkgSettings.Force) packageConfig.Force = true;
741741
packageConfig.CommandExecutionTimeoutSeconds = pkgSettings.Timeout == -1 ? packageConfig.CommandExecutionTimeoutSeconds : pkgSettings.Timeout;
742+
if (pkgSettings.Prerelease) packageConfig.Prerelease = true;
743+
if (pkgSettings.OverrideArguments) packageConfig.OverrideArguments = true;
744+
if (pkgSettings.NotSilent) packageConfig.NotSilent = true;
745+
if (pkgSettings.AllowDowngrade) packageConfig.AllowDowngrade = true;
746+
if (pkgSettings.ForceDependencies) packageConfig.ForceDependencies = true;
747+
if (pkgSettings.SkipAutomationScripts) packageConfig.SkipPackageInstallProvider = true;
748+
packageConfig.SourceCommand.Username = string.IsNullOrWhiteSpace(pkgSettings.User) ? packageConfig.SourceCommand.Username : pkgSettings.User;
749+
packageConfig.SourceCommand.Password = string.IsNullOrWhiteSpace(pkgSettings.Password) ? packageConfig.SourceCommand.Password : pkgSettings.Password;
750+
packageConfig.SourceCommand.Certificate = string.IsNullOrWhiteSpace(pkgSettings.Cert) ? packageConfig.SourceCommand.Certificate : pkgSettings.Cert;
751+
packageConfig.SourceCommand.CertificatePassword = string.IsNullOrWhiteSpace(pkgSettings.CertPassword) ? packageConfig.SourceCommand.CertificatePassword : pkgSettings.CertPassword;
752+
if (pkgSettings.IgnoreChecksums) packageConfig.Features.ChecksumFiles = false;
753+
if (pkgSettings.AllowEmptyChecksums) packageConfig.Features.AllowEmptyChecksums = true;
754+
if (pkgSettings.AllowEmptyChecksumsSecure) packageConfig.Features.AllowEmptyChecksumsSecure = true;
755+
if (pkgSettings.RequireChecksums)
756+
{
757+
packageConfig.Features.AllowEmptyChecksums = false;
758+
packageConfig.Features.AllowEmptyChecksumsSecure = false;
759+
}
760+
packageConfig.DownloadChecksum = string.IsNullOrWhiteSpace(pkgSettings.DownloadChecksum) ? packageConfig.DownloadChecksum : pkgSettings.DownloadChecksum;
761+
packageConfig.DownloadChecksum64 = string.IsNullOrWhiteSpace(pkgSettings.DownloadChecksum64) ? packageConfig.DownloadChecksum64 : pkgSettings.DownloadChecksum64;
762+
packageConfig.DownloadChecksum = string.IsNullOrWhiteSpace(pkgSettings.DownloadChecksumType) ? packageConfig.DownloadChecksumType : pkgSettings.DownloadChecksumType;
763+
packageConfig.DownloadChecksumType64 = string.IsNullOrWhiteSpace(pkgSettings.DownloadChecksumType64) ? packageConfig.DownloadChecksumType : pkgSettings.DownloadChecksumType64;
764+
if (pkgSettings.IgnorePackageExitCodes) packageConfig.Features.UsePackageExitCodes = false;
765+
if (pkgSettings.UsePackageExitCodes) packageConfig.Features.UsePackageExitCodes = true;
766+
if (pkgSettings.StopOnFirstFailure) packageConfig.Features.StopOnFirstPackageFailure = true;
767+
if (pkgSettings.ExitWhenRebootDetected) packageConfig.Features.ExitOnRebootDetected = true;
768+
if (pkgSettings.IgnoreDetectedReboot) packageConfig.Features.ExitOnRebootDetected = false;
769+
if (pkgSettings.DisableRepositoryOptimizations) packageConfig.Features.UsePackageRepositoryOptimizations = false;
742770

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

0 commit comments

Comments
 (0)