diff --git a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyExportCommandSpecs.cs b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyExportCommandSpecs.cs index 7bcc4a673d..83749eb799 100644 --- a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyExportCommandSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyExportCommandSpecs.cs @@ -117,6 +117,12 @@ public void should_add_include_remembered_arguments_to_the_option_set() { optionSet.Contains("include-remembered-arguments").ShouldBeTrue(); } + + [Fact] + public void should_add_exclude_pins_to_the_option_set() + { + optionSet.Contains("exclude-pins").ShouldBeTrue(); + } } public class when_handling_additional_argument_parsing : ChocolateyExportCommandSpecsBase diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyExportCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyExportCommand.cs index fffb495995..b278fbc8ea 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyExportCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyExportCommand.cs @@ -58,6 +58,9 @@ public void configure_argument_parser(OptionSet optionSet, ChocolateyConfigurati .Add("include-arguments|include-remembered-arguments", "Include Remembered Arguments - controls whether or not remembered arguments for each package appear in generated file. Defaults to false.", option => configuration.ExportCommand.IncludeRememberedPackageArguments = option != null) + .Add("exclude-pins", + "Exclude Pins - controls whether or not pins are included. Only applies if remembered arguments are exported. Defaults to false.", + option => configuration.ExportCommand.ExcludePins = option != null) ; } @@ -104,6 +107,7 @@ public void help_message(ChocolateyConfiguration configuration) choco export choco export --include-version-numbers choco export --include-version-numbers --include-remembered-arguments + choco export --include-remembered-arguments --exclude-pins choco export ""'c:\temp\packages.config'"" choco export ""'c:\temp\packages.config'"" --include-version-numbers choco export -o=""'c:\temp\packages.config'"" @@ -141,7 +145,11 @@ public bool may_require_admin_access() public void noop(ChocolateyConfiguration configuration) { - this.Log().Info("Export would have been with options: {0} Output File Path={1}{0} Include Version Numbers:{2}{0} Include Remembered Arguments: {3}".format_with(Environment.NewLine, configuration.ExportCommand.OutputFilePath, configuration.ExportCommand.IncludeVersionNumbers, configuration.ExportCommand.IncludeRememberedPackageArguments)); + this.Log().Info("Export would have been with options: {0} Output File Path={1}{0} Include Version Numbers:{2}{0} Include Remembered Arguments: {3}{0} Exclude Pins: {4}".format_with( + Environment.NewLine, configuration.ExportCommand.OutputFilePath, + configuration.ExportCommand.IncludeVersionNumbers, + configuration.ExportCommand.IncludeRememberedPackageArguments, + configuration.ExportCommand.ExcludePins)); } public void run(ChocolateyConfiguration configuration) @@ -221,6 +229,11 @@ public void run(ChocolateyConfiguration configuration) //Make sure to reset the configuration configuration = originalConfiguration.deep_copy(); + + if (!configuration.ExportCommand.ExcludePins && pkgInfo.IsPinned) + { + xw.WriteAttributeString("pinPackage", "true"); + } } xw.WriteEndElement(); diff --git a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs index 261b209b85..a2da79b292 100644 --- a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs +++ b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs @@ -562,6 +562,7 @@ public sealed class ExportCommandConfiguration { public bool IncludeVersionNumbers { get; set; } public bool IncludeRememberedPackageArguments { get; set; } + public bool ExcludePins { get; set; } public string OutputFilePath { get; set; } }