Skip to content

Commit 17f00eb

Browse files
committed
Merge branch 'stable'
* stable: (GH-1774) log on failing repo (GH-1770) Feature - usePackageRepositoryOptimizations (GH-1771) Download nupkg, extract nuspec (maint) formatting (maint) ensure config for removing nuget cache (doc) update copyright year
2 parents 389236f + 1ff4ab2 commit 17f00eb

12 files changed

+101
-47
lines changed

Diff for: .uppercut

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<property name="version.nuget.prerelease" value="" overwrite="false" />
2323
<property name="version.use.build_date" value="false" overwrite="false" />
2424
<property name="assembly.description" value="${project.name} is a product of ${company.name} - All Rights Reserved." overwrite="false" />
25-
<property name="assembly.copyright" value="Copyright © 2017 - 2018 ${company.name} Copyright © 2011 - 2017, RealDimensions Software, LLC - All Rights Reserved." overwrite="false" />
25+
<property name="assembly.copyright" value="Copyright © 2017 - 2019 ${company.name} Copyright © 2011 - 2017, RealDimensions Software, LLC - All Rights Reserved." overwrite="false" />
2626
<property name="sign.project_with_key" value="true" overwrite="false" />
2727

2828
<!-- Build Features Overrides -->

Diff for: nuget/chocolatey.lib/chocolatey.lib.nuspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<iconUrl>https://raw.githubusercontent.com/chocolatey/choco/master/docs/logo/chocolateyicon.gif</iconUrl>
1111
<licenseUrl>https://raw.githubusercontent.com/chocolatey/choco/master/LICENSE</licenseUrl>
1212
<requireLicenseAcceptance>false</requireLicenseAcceptance>
13-
<copyright>2017 Chocolatey Software, Inc, 2011- 2017 RealDimensions Software, LLC</copyright>
13+
<copyright>2017-2019 Chocolatey Software, Inc, 2011- 2017 RealDimensions Software, LLC</copyright>
1414
<tags>apt-get machine repository chocolatey</tags>
1515
<summary>Chocolatey is the package manager for Windows (like apt-get but for Windows)</summary>
1616
<description>

Diff for: nuget/chocolatey/chocolatey.nuspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<iconUrl>https://raw.githubusercontent.com/chocolatey/choco/master/docs/logo/chocolateyicon.gif</iconUrl>
1212
<licenseUrl>https://raw.githubusercontent.com/chocolatey/choco/master/LICENSE</licenseUrl>
1313
<requireLicenseAcceptance>false</requireLicenseAcceptance>
14-
<copyright>2017 Chocolatey Software, Inc, 2011- 2017 RealDimensions Software, LLC</copyright>
14+
<copyright>2017-2019 Chocolatey Software, Inc, 2011- 2017 RealDimensions Software, LLC</copyright>
1515
<!--<projectSourceUrl>https://github.com/chocolatey/choco</projectSourceUrl>
1616
<docsUrl>https://chocolatey.org/docs</docsUrl>
1717
<mailingListUrl>https://groups.google.com/forum/#!forum/chocolatey</mailingListUrl>

Diff for: src/chocolatey/infrastructure.app/ApplicationParameters.cs

+1
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ public static class Features
180180
public static readonly string LogWithoutColor = "logWithoutColor";
181181
public static readonly string ExitOnRebootDetected = "exitOnRebootDetected";
182182
public static readonly string LogValidationResultsOnWarnings = "logValidationResultsOnWarnings";
183+
public static readonly string UsePackageRepositoryOptimizations = "usePackageRepositoryOptimizations";
183184
}
184185

185186
public static class Messages

Diff for: src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs

+1
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ private static void set_feature_flags(ChocolateyConfiguration config, ConfigFile
304304
config.Features.RemovePackageInformationOnUninstall = set_feature_flag(ApplicationParameters.Features.RemovePackageInformationOnUninstall, configFileSettings, defaultEnabled: false, description: "Remove Stored Package Information On Uninstall - When a package is uninstalled, should the stored package information also be removed? Available in 0.10.9+.");
305305
config.Features.LogWithoutColor = set_feature_flag(ApplicationParameters.Features.LogWithoutColor, configFileSettings, defaultEnabled: false, description: "Log without color - Do not show colorization in logging output. Available in 0.10.9+.");
306306
config.Features.LogValidationResultsOnWarnings = set_feature_flag(ApplicationParameters.Features.LogValidationResultsOnWarnings, configFileSettings, defaultEnabled: true, description: "Log validation results on warnings - Should the validation results be logged if there are warnings? Available in 0.10.12+.");
307+
config.Features.UsePackageRepositoryOptimizations = set_feature_flag(ApplicationParameters.Features.UsePackageRepositoryOptimizations, configFileSettings, defaultEnabled: true, description: "Use Package Repository Optimizations - Turn on optimizations for reducing bandwidth with repository queries during package install/upgrade/outdated operations. Should generally be left enabled, unless a repository needs to support older methods of query. When disabled, this makes queries similar to the way they were done in Chocolatey v0.10.11 and before. Available in 0.10.14+.");
307308
config.Features.ScriptsCheckLastExitCode = set_feature_flag(ApplicationParameters.Features.ScriptsCheckLastExitCode, configFileSettings, defaultEnabled: false, description: "Scripts Check $LastExitCode (external commands) - Leave this off unless you absolutely need it while you fix your package scripts to use `throw 'error message'` or `Set-PowerShellExitCode #` instead of `exit #`. This behavior started in 0.9.10 and produced hard to find bugs. If the last external process exits successfully but with an exit code of not zero, this could cause hard to detect package failures. Available in 0.10.3+. Will be removed in 0.11.0.");
308309
config.PromptForConfirmation = !set_feature_flag(ApplicationParameters.Features.AllowGlobalConfirmation, configFileSettings, defaultEnabled: false, description: "Prompt for confirmation in scripts or bypass.");
309310
}

Diff for: src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs

+12-2
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
156156
option => configuration.Features.StopOnFirstPackageFailure = option != null
157157
)
158158
.Add("exitwhenrebootdetected|exit-when-reboot-detected",
159-
"Exit When Reboot Detected - Stop running install, upgrade, or uninstall when a reboot request is detected. Requires '{0}' feature to be turned on. Will exit with either {1} or {2}. Overrides the default feature '{3}' set to '{4}'. Available in 0.10.12+.".format_with
159+
"Exit When Reboot Detected - Stop running install, upgrade, or uninstall when a reboot request is detected. Requires '{0}' feature to be turned on. Will exit with either {1} or {2}. Overrides the default feature '{3}' set to '{4}'. Available in 0.10.12+.".format_with
160160
(ApplicationParameters.Features.UsePackageExitCodes, ApplicationParameters.ExitCodes.ErrorFailNoActionReboot, ApplicationParameters.ExitCodes.ErrorInstallSuspend, ApplicationParameters.Features.ExitOnRebootDetected, configuration.Features.ExitOnRebootDetected.to_string()),
161161
option => configuration.Features.ExitOnRebootDetected = option != null
162162
)
163163
.Add("ignoredetectedreboot|ignore-detected-reboot",
164-
"Ignore Detected Reboot - Ignore any detected reboots if found. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.12+.".format_with
164+
"Ignore Detected Reboot - Ignore any detected reboots if found. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.12+.".format_with
165165
(ApplicationParameters.Features.ExitOnRebootDetected, configuration.Features.ExitOnRebootDetected.to_string()),
166166
option =>
167167
{
@@ -170,6 +170,16 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
170170
configuration.Features.ExitOnRebootDetected = false;
171171
}
172172
})
173+
.Add("disable-repository-optimizations|disable-package-repository-optimizations",
174+
"Disable Package Repository Optimizations - Do not use optimizations for reducing bandwidth with repository queries during package install/upgrade/outdated operations. Should not generally be used, unless a repository needs to support older methods of query. When used, this makes queries similar to the way they were done in Chocolatey v0.10.11 and before. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.14+.".format_with
175+
(ApplicationParameters.Features.UsePackageRepositoryOptimizations, configuration.Features.UsePackageRepositoryOptimizations.to_string()),
176+
option =>
177+
{
178+
if (option != null)
179+
{
180+
configuration.Features.UsePackageRepositoryOptimizations = false;
181+
}
182+
})
173183
;
174184

175185
//todo: package name can be a url / installertype

Diff for: src/chocolatey/infrastructure.app/commands/ChocolateyOutdatedCommand.cs

+10
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
5858
.Add("ignore-unfound",
5959
"Ignore Unfound Packages - Ignore packages that are not found on the sources used (or the defaults). Overrides the default feature '{0}' set to '{1}'. Available in 0.10.9+.".format_with(ApplicationParameters.Features.IgnoreUnfoundPackagesOnUpgradeOutdated, configuration.Features.IgnoreUnfoundPackagesOnUpgradeOutdated.to_string()),
6060
option => configuration.Features.IgnoreUnfoundPackagesOnUpgradeOutdated = option != null)
61+
.Add("disable-repository-optimizations|disable-package-repository-optimizations",
62+
"Disable Package Repository Optimizations - Do not use optimizations for reducing bandwidth with repository queries during package install/upgrade/outdated operations. Should not generally be used, unless a repository needs to support older methods of query. When disabled, this makes queries similar to the way they were done in Chocolatey v0.10.11 and before. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.14+.".format_with
63+
(ApplicationParameters.Features.UsePackageRepositoryOptimizations, configuration.Features.UsePackageRepositoryOptimizations.to_string()),
64+
option =>
65+
{
66+
if (option != null)
67+
{
68+
configuration.Features.UsePackageRepositoryOptimizations = false;
69+
}
70+
})
6171
;
6272
}
6373

Diff for: src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs

+20-10
Original file line numberDiff line numberDiff line change
@@ -185,23 +185,23 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
185185
)
186186
.Add("userememberedargs|userememberedarguments|userememberedoptions|use-remembered-args|use-remembered-arguments|use-remembered-options",
187187
"Use Remembered Options for Upgrade - use the arguments and options used during install for upgrade. Does not override arguments being passed at runtime. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.4+.".format_with(ApplicationParameters.Features.UseRememberedArgumentsForUpgrades, configuration.Features.UseRememberedArgumentsForUpgrades.to_string()),
188-
option =>
189-
{
190-
if (option != null) configuration.Features.UseRememberedArgumentsForUpgrades = true;
191-
})
188+
option =>
189+
{
190+
if (option != null) configuration.Features.UseRememberedArgumentsForUpgrades = true;
191+
})
192192
.Add("ignorerememberedargs|ignorerememberedarguments|ignorerememberedoptions|ignore-remembered-args|ignore-remembered-arguments|ignore-remembered-options",
193193
"Ignore Remembered Options for Upgrade - ignore the arguments and options used during install for upgrade. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.4+.".format_with(ApplicationParameters.Features.UseRememberedArgumentsForUpgrades, configuration.Features.UseRememberedArgumentsForUpgrades.to_string()),
194-
option =>
195-
{
196-
if (option != null) configuration.Features.UseRememberedArgumentsForUpgrades = false;
197-
})
194+
option =>
195+
{
196+
if (option != null) configuration.Features.UseRememberedArgumentsForUpgrades = false;
197+
})
198198
.Add("exitwhenrebootdetected|exit-when-reboot-detected",
199-
"Exit When Reboot Detected - Stop running install, upgrade, or uninstall when a reboot request is detected. Requires '{0}' feature to be turned on. Will exit with either {1} or {2}. Overrides the default feature '{3}' set to '{4}'. Available in 0.10.12+.".format_with
199+
"Exit When Reboot Detected - Stop running install, upgrade, or uninstall when a reboot request is detected. Requires '{0}' feature to be turned on. Will exit with either {1} or {2}. Overrides the default feature '{3}' set to '{4}'. Available in 0.10.12+.".format_with
200200
(ApplicationParameters.Features.UsePackageExitCodes, ApplicationParameters.ExitCodes.ErrorFailNoActionReboot, ApplicationParameters.ExitCodes.ErrorInstallSuspend, ApplicationParameters.Features.ExitOnRebootDetected, configuration.Features.ExitOnRebootDetected.to_string()),
201201
option => configuration.Features.ExitOnRebootDetected = option != null
202202
)
203203
.Add("ignoredetectedreboot|ignore-detected-reboot",
204-
"Ignore Detected Reboot - Ignore any detected reboots if found. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.12+.".format_with
204+
"Ignore Detected Reboot - Ignore any detected reboots if found. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.12+.".format_with
205205
(ApplicationParameters.Features.ExitOnRebootDetected, configuration.Features.ExitOnRebootDetected.to_string()),
206206
option =>
207207
{
@@ -210,6 +210,16 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
210210
configuration.Features.ExitOnRebootDetected = false;
211211
}
212212
})
213+
.Add("disable-repository-optimizations|disable-package-repository-optimizations",
214+
"Disable Package Repository Optimizations - Do not use optimizations for reducing bandwidth with repository queries during package install/upgrade/outdated operations. Should not generally be used, unless a repository needs to support older methods of query. When disabled, this makes queries similar to the way they were done in Chocolatey v0.10.11 and before. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.14+.".format_with
215+
(ApplicationParameters.Features.UsePackageRepositoryOptimizations, configuration.Features.UsePackageRepositoryOptimizations.to_string()),
216+
option =>
217+
{
218+
if (option != null)
219+
{
220+
configuration.Features.UsePackageRepositoryOptimizations = false;
221+
}
222+
})
213223
;
214224
}
215225

Diff for: src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs

+1
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ public sealed class FeaturesConfiguration
394394
public bool RemovePackageInformationOnUninstall { get; set; }
395395
public bool ExitOnRebootDetected { get; set; }
396396
public bool LogValidationResultsOnWarnings { get; set; }
397+
public bool UsePackageRepositoryOptimizations { get; set; }
397398

398399
//todo remove in 0.11.0
399400
public bool ScriptsCheckLastExitCode { get; set; }

Diff for: src/chocolatey/infrastructure.app/nuget/ChocolateyLocalPackageRepository.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace chocolatey.infrastructure.app.nuget
2121
using System.IO;
2222
using System.Linq;
2323
using System.Runtime.Versioning;
24+
using System.Threading;
2425
using NuGet;
2526

2627
// ReSharper disable InconsistentNaming
@@ -50,10 +51,15 @@ public ChocolateyLocalPackageRepository(IPackagePathResolver pathResolver, IFile
5051
public override void AddPackage(IPackage package)
5152
{
5253
string packageFilePath = GetPackageFilePath(package);
54+
FileSystem.AddFileWithCheck(packageFilePath, package.GetStream);
55+
// allow the file to finish being written
56+
Thread.Sleep(200);
5357
if (PackageSaveMode.HasFlag(PackageSaveModes.Nuspec))
5458
{
59+
// don't trust the package metadata to be complete - extract from the downloaded nupkg
60+
var zipPackage = new OptimizedZipPackage(FileSystem, packageFilePath);
5561
string manifestFilePath = GetManifestFilePath(package.Id, package.Version);
56-
Manifest manifest = Manifest.Create(package);
62+
Manifest manifest = Manifest.Create(zipPackage);
5763
manifest.Metadata.ReferenceSets = Enumerable.ToList<ManifestReferenceSet>(Enumerable.Select<IGrouping<FrameworkName, IPackageAssemblyReference>, ManifestReferenceSet>(Enumerable.GroupBy<IPackageAssemblyReference, FrameworkName>(package.AssemblyReferences, (Func<IPackageAssemblyReference, FrameworkName>)(f => f.TargetFramework)), (Func<IGrouping<FrameworkName, IPackageAssemblyReference>, ManifestReferenceSet>)(g => new ManifestReferenceSet()
5864
{
5965
TargetFramework = g.Key == (FrameworkName)null ? (string)null : VersionUtility.GetFrameworkString(g.Key),
@@ -64,8 +70,6 @@ public override void AddPackage(IPackage package)
6470
})));
6571
FileSystem.AddFileWithCheck(manifestFilePath, manifest.Save);
6672
}
67-
68-
FileSystem.AddFileWithCheck(packageFilePath, package.GetStream);
6973
}
7074

7175
private string GetManifestFilePath(string packageId, SemanticVersion version)

Diff for: src/chocolatey/infrastructure.app/runners/GenericRunner.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ namespace chocolatey.infrastructure.app.runners
3131
using configuration;
3232
using domain;
3333
using infrastructure.commands;
34+
using infrastructure.configuration;
3435
using logging;
3536
using Console = System.Console;
3637
using Environment = System.Environment;
@@ -182,7 +183,7 @@ public void run(ChocolateyConfiguration config, Container container, bool isCons
182183
/// <param name="container">The container.</param>
183184
private void remove_nuget_cache(Container container)
184185
{
185-
remove_nuget_cache(container, null);
186+
remove_nuget_cache(container, Config.get_configuration_settings());
186187
}
187188

188189
/// <summary>

0 commit comments

Comments
 (0)