From 9f64437d143b77e56a3ad299a82ca52a42cc47a9 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Tue, 6 Jun 2023 08:57:25 +0100 Subject: [PATCH 01/18] (maint) Update to latest Chocolatey.Lib package This contains some changes in how SourceCacheContexts can be passed into the NuGet.Client methods, and any corresponding changes need to be made into the Chocolatey GUI codebase. --- .../ChocolateyGui.Common.Windows.csproj | 4 ++-- Source/ChocolateyGui.Common.Windows/packages.config | 2 +- Source/ChocolateyGui.Common/ChocolateyGui.Common.csproj | 4 ++-- Source/ChocolateyGui.Common/packages.config | 2 +- Source/ChocolateyGui/ChocolateyGui.csproj | 4 ++-- Source/ChocolateyGui/packages.config | 2 +- Source/ChocolateyGuiCli/ChocolateyGuiCli.csproj | 4 ++-- Source/ChocolateyGuiCli/packages.config | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/ChocolateyGui.Common.Windows/ChocolateyGui.Common.Windows.csproj b/Source/ChocolateyGui.Common.Windows/ChocolateyGui.Common.Windows.csproj index 7067166d5..a695ca042 100644 --- a/Source/ChocolateyGui.Common.Windows/ChocolateyGui.Common.Windows.csproj +++ b/Source/ChocolateyGui.Common.Windows/ChocolateyGui.Common.Windows.csproj @@ -1,4 +1,4 @@ - + @@ -68,7 +68,7 @@ ..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.Core.dll - ..\packages\chocolatey.lib.2.0.0\lib\net48\chocolatey.dll + ..\packages\chocolatey.lib.2.1.0-alpha-20230605-1278\lib\net48\chocolatey.dll False False diff --git a/Source/ChocolateyGui.Common.Windows/packages.config b/Source/ChocolateyGui.Common.Windows/packages.config index 0407ee0ea..24d4fbf68 100644 --- a/Source/ChocolateyGui.Common.Windows/packages.config +++ b/Source/ChocolateyGui.Common.Windows/packages.config @@ -5,7 +5,7 @@ - + diff --git a/Source/ChocolateyGui.Common/ChocolateyGui.Common.csproj b/Source/ChocolateyGui.Common/ChocolateyGui.Common.csproj index 5e06ea85c..e06795243 100644 --- a/Source/ChocolateyGui.Common/ChocolateyGui.Common.csproj +++ b/Source/ChocolateyGui.Common/ChocolateyGui.Common.csproj @@ -1,4 +1,4 @@ - + @@ -55,7 +55,7 @@ ..\packages\AutoMapper.7.0.1\lib\net45\AutoMapper.dll - ..\packages\chocolatey.lib.2.0.0\lib\net48\chocolatey.dll + ..\packages\chocolatey.lib.2.1.0-alpha-20230605-1278\lib\net48\chocolatey.dll False False diff --git a/Source/ChocolateyGui.Common/packages.config b/Source/ChocolateyGui.Common/packages.config index f636e71aa..cb66149a9 100644 --- a/Source/ChocolateyGui.Common/packages.config +++ b/Source/ChocolateyGui.Common/packages.config @@ -3,7 +3,7 @@ - + diff --git a/Source/ChocolateyGui/ChocolateyGui.csproj b/Source/ChocolateyGui/ChocolateyGui.csproj index 20b305839..be8fbb9fb 100644 --- a/Source/ChocolateyGui/ChocolateyGui.csproj +++ b/Source/ChocolateyGui/ChocolateyGui.csproj @@ -1,4 +1,4 @@ - + @@ -114,7 +114,7 @@ ..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.Core.dll - ..\packages\chocolatey.lib.2.0.0\lib\net48\chocolatey.dll + ..\packages\chocolatey.lib.2.1.0-alpha-20230605-1278\lib\net48\chocolatey.dll False False diff --git a/Source/ChocolateyGui/packages.config b/Source/ChocolateyGui/packages.config index cb66bc128..4534f372a 100644 --- a/Source/ChocolateyGui/packages.config +++ b/Source/ChocolateyGui/packages.config @@ -5,7 +5,7 @@ - + diff --git a/Source/ChocolateyGuiCli/ChocolateyGuiCli.csproj b/Source/ChocolateyGuiCli/ChocolateyGuiCli.csproj index dd2c9dadd..af50b6c6b 100644 --- a/Source/ChocolateyGuiCli/ChocolateyGuiCli.csproj +++ b/Source/ChocolateyGuiCli/ChocolateyGuiCli.csproj @@ -1,4 +1,4 @@ - + @@ -57,7 +57,7 @@ ..\packages\Autofac.4.6.1\lib\net45\Autofac.dll - ..\packages\chocolatey.lib.2.0.0\lib\net48\chocolatey.dll + ..\packages\chocolatey.lib.2.1.0-alpha-20230605-1278\lib\net48\chocolatey.dll False False diff --git a/Source/ChocolateyGuiCli/packages.config b/Source/ChocolateyGuiCli/packages.config index d9137d44f..88aab42d2 100644 --- a/Source/ChocolateyGuiCli/packages.config +++ b/Source/ChocolateyGuiCli/packages.config @@ -2,7 +2,7 @@ - + From 8b1b072c2f18a63c3aed5452f74d19ef6288f5d1 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Tue, 6 Jun 2023 08:58:44 +0100 Subject: [PATCH 02/18] (maint) Remove usage of obsolete methods A number of methods in Chocolatey CLI have been replaced with renamed versions that do exactly the same thing as before. This commit switches to using those newly named methods, rather than the old ones. --- Source/ChocolateyGuiCli/Bootstrapper.cs | 10 +++++----- Source/ChocolateyGuiCli/Runner.cs | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/ChocolateyGuiCli/Bootstrapper.cs b/Source/ChocolateyGuiCli/Bootstrapper.cs index 180b0daf0..64c87928f 100644 --- a/Source/ChocolateyGuiCli/Bootstrapper.cs +++ b/Source/ChocolateyGuiCli/Bootstrapper.cs @@ -25,13 +25,13 @@ public static class Bootstrapper // Due to an unknown reason, we can not use chocolateys own get_current_assembly() function here, // as it will be returning the path to the choco.exe executable instead. - public static readonly string ChocolateyGuiInstallLocation = _fileSystem.get_directory_name(Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", string.Empty)); + public static readonly string ChocolateyGuiInstallLocation = _fileSystem.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", string.Empty)); public static readonly string ChocolateyInstallEnvironmentVariableName = "ChocolateyInstall"; - public static readonly string ChocolateyInstallLocation = System.Environment.GetEnvironmentVariable(ChocolateyInstallEnvironmentVariableName) ?? _fileSystem.get_directory_name(_fileSystem.get_current_assembly_path()); - public static readonly string LicensedGuiAssemblyLocation = _fileSystem.combine_paths(ChocolateyInstallLocation, "extensions", "chocolateygui", "chocolateygui.licensed.dll"); + public static readonly string ChocolateyInstallLocation = System.Environment.GetEnvironmentVariable(ChocolateyInstallEnvironmentVariableName) ?? _fileSystem.GetDirectoryName(_fileSystem.GetCurrentAssemblyPath()); + public static readonly string LicensedGuiAssemblyLocation = _fileSystem.CombinePaths(ChocolateyInstallLocation, "extensions", "chocolateygui", "chocolateygui.licensed.dll"); - public static readonly string ChocolateyGuiCommonAssemblyLocation = _fileSystem.combine_paths(ChocolateyGuiInstallLocation, "ChocolateyGui.Common.dll"); - public static readonly string ChocolateyGuiCommonWindowsAssemblyLocation = _fileSystem.combine_paths(ChocolateyGuiInstallLocation, "ChocolateyGui.Common.Windows.dll"); + public static readonly string ChocolateyGuiCommonAssemblyLocation = _fileSystem.CombinePaths(ChocolateyGuiInstallLocation, "ChocolateyGui.Common.dll"); + public static readonly string ChocolateyGuiCommonWindowsAssemblyLocation = _fileSystem.CombinePaths(ChocolateyGuiInstallLocation, "ChocolateyGui.Common.Windows.dll"); public static readonly string ChocolateyGuiCommonAssemblySimpleName = "ChocolateyGui.Common"; public static readonly string ChocolateyGuiCommonWindowsAssemblySimpleName = "ChocolateyGui.Common.Windows"; diff --git a/Source/ChocolateyGuiCli/Runner.cs b/Source/ChocolateyGuiCli/Runner.cs index 835c63af4..b732ab1a5 100644 --- a/Source/ChocolateyGuiCli/Runner.cs +++ b/Source/ChocolateyGuiCli/Runner.cs @@ -69,7 +69,7 @@ public static void Run(string[] args) if (configuration.RegularOutput) { #if DEBUG - Bootstrapper.Logger.Warning(" (DEBUG BUILD)".format_with("Chocolatey GUI", configuration.Information.DisplayVersion)); + Bootstrapper.Logger.Warning(" (DEBUG BUILD)".FormatWith("Chocolatey GUI", configuration.Information.DisplayVersion)); #else Bootstrapper.Logger.Warning("{0}".format_with(configuration.Information.DisplayVersion)); #endif @@ -159,10 +159,10 @@ private static void SetUpGlobalOptions(IList args, ChocolateyGuiConfigur { var commandsLog = new StringBuilder(); var commands = container.Resolve>(); - foreach (var command in commands.or_empty_list_if_null()) + foreach (var command in commands.OrEmpty()) { var attributes = command.GetType().GetCustomAttributes(typeof(LocalizedCommandForAttribute), false).Cast(); - foreach (var attribute in attributes.or_empty_list_if_null()) + foreach (var attribute in attributes.OrEmpty()) { commandsLog.AppendFormat(" * {0} - {1}\n", attribute.CommandName, attribute.Description); } @@ -172,7 +172,7 @@ private static void SetUpGlobalOptions(IList args, ChocolateyGuiConfigur Bootstrapper.Logger.Information(string.Empty); Bootstrapper.Logger.Warning(L(nameof(ChocolateyGui.Common.Properties.Resources.Command_CommandsTitle))); Bootstrapper.Logger.Information(string.Empty); - Bootstrapper.Logger.Information("{0}".format_with(commandsLog.ToString())); + Bootstrapper.Logger.Information("{0}".FormatWith(commandsLog.ToString())); Bootstrapper.Logger.Information(L(nameof(ChocolateyGui.Common.Properties.Resources.Command_CommandsText), "chocolateyguicli")); Bootstrapper.Logger.Information(string.Empty); Bootstrapper.Logger.Warning(L(nameof(ChocolateyGui.Common.Properties.Resources.Command_DefaultOptionsAndSwitches))); @@ -232,7 +232,7 @@ private static void ParseArgumentsAndUpdateConfiguration( { configuration.CommandName = commandName; } - else if (commandName.is_equal_to("-v") || commandName.is_equal_to("--version")) + else if (commandName.IsEqualTo("-v") || commandName.IsEqualTo("--version")) { // skip help menu } From 540211530c930afc340e1055b433e4276ba22181 Mon Sep 17 00:00:00 2001 From: AdmiringWorm Date: Fri, 2 Jun 2023 14:26:06 +0200 Subject: [PATCH 03/18] (maint) Add banned api analyzer This adds the microsoft banned API analyzer to the projects to prevent usages of certain methods and types that have alternatives that are preferable to be used instead. --- .editorconfig | 2 ++ .../ChocolateyGui.Common.Windows.csproj | 7 +++++++ Source/ChocolateyGui.Common.Windows/packages.config | 1 + Source/ChocolateyGui.Common/ChocolateyGui.Common.csproj | 7 +++++++ Source/ChocolateyGui.Common/packages.config | 1 + Source/ChocolateyGui/BannedSymbols.txt | 6 ++++++ Source/ChocolateyGui/ChocolateyGui.csproj | 3 +++ Source/ChocolateyGui/packages.config | 1 + Source/ChocolateyGuiCli/ChocolateyGuiCli.csproj | 7 +++++++ Source/ChocolateyGuiCli/packages.config | 1 + 10 files changed, 36 insertions(+) create mode 100644 Source/ChocolateyGui/BannedSymbols.txt diff --git a/.editorconfig b/.editorconfig index 92f475bca..108d2a4ba 100644 --- a/.editorconfig +++ b/.editorconfig @@ -73,3 +73,5 @@ csharp_style_pattern_matching_over_as_with_null_check = true:suggestion csharp_style_inlined_variable_declaration = true:suggestion csharp_style_throw_expression = true:suggestion csharp_style_conditional_delegate_call = true:suggestion +dotnet_diagnostic.RS0030.severity = error +dotnet_diagnostic.RS0031.severity = error diff --git a/Source/ChocolateyGui.Common.Windows/ChocolateyGui.Common.Windows.csproj b/Source/ChocolateyGui.Common.Windows/ChocolateyGui.Common.Windows.csproj index a695ca042..cdbca143c 100644 --- a/Source/ChocolateyGui.Common.Windows/ChocolateyGui.Common.Windows.csproj +++ b/Source/ChocolateyGui.Common.Windows/ChocolateyGui.Common.Windows.csproj @@ -422,9 +422,16 @@ + + + + + BannedSymbols.txt + + diff --git a/Source/ChocolateyGui.Common.Windows/packages.config b/Source/ChocolateyGui.Common.Windows/packages.config index 24d4fbf68..30ad803ef 100644 --- a/Source/ChocolateyGui.Common.Windows/packages.config +++ b/Source/ChocolateyGui.Common.Windows/packages.config @@ -20,6 +20,7 @@ + diff --git a/Source/ChocolateyGui.Common/ChocolateyGui.Common.csproj b/Source/ChocolateyGui.Common/ChocolateyGui.Common.csproj index e06795243..8e077a25a 100644 --- a/Source/ChocolateyGui.Common/ChocolateyGui.Common.csproj +++ b/Source/ChocolateyGui.Common/ChocolateyGui.Common.csproj @@ -226,6 +226,8 @@ + + @@ -233,5 +235,10 @@ + + + BannedSymbols.txt + + \ No newline at end of file diff --git a/Source/ChocolateyGui.Common/packages.config b/Source/ChocolateyGui.Common/packages.config index cb66149a9..f14a3eda7 100644 --- a/Source/ChocolateyGui.Common/packages.config +++ b/Source/ChocolateyGui.Common/packages.config @@ -6,6 +6,7 @@ + diff --git a/Source/ChocolateyGui/BannedSymbols.txt b/Source/ChocolateyGui/BannedSymbols.txt new file mode 100644 index 000000000..c1c3f98a2 --- /dev/null +++ b/Source/ChocolateyGui/BannedSymbols.txt @@ -0,0 +1,6 @@ +M:NuGet.Versioning.SemanticVersion.ToFullString;Use ToFullStringChecked() extension method instead. +M:Chocolatey.NuGet.Versioning.SemanticVersion.ToFullString();Use ToFullStringChecked() extension method instead. +M:NuGet.Versioning.SemanticVersion.ToNormalizedString;Use ToNormalizedStringChecked() extension method instead. +M:Chocolatey.NuGet.Versioning.SemanticVersion.ToNormalizedString();Use ToNormalizedStringChecked() extension method instead. +M:NuGet.Versioning.SemanticVersion.ToString;Use ToNormalizedStringChecked() extension method instead. +M:Chocolatey.NuGet.Versioning.SemanticVersion.ToString();Use ToNormalizedStringChecked() extension method instead. \ No newline at end of file diff --git a/Source/ChocolateyGui/ChocolateyGui.csproj b/Source/ChocolateyGui/ChocolateyGui.csproj index be8fbb9fb..fa4ffbe7f 100644 --- a/Source/ChocolateyGui/ChocolateyGui.csproj +++ b/Source/ChocolateyGui/ChocolateyGui.csproj @@ -320,6 +320,7 @@ Designer + Designer Always @@ -343,6 +344,8 @@ + + diff --git a/Source/ChocolateyGui/packages.config b/Source/ChocolateyGui/packages.config index 4534f372a..c2ddf56d5 100644 --- a/Source/ChocolateyGui/packages.config +++ b/Source/ChocolateyGui/packages.config @@ -20,6 +20,7 @@ + diff --git a/Source/ChocolateyGuiCli/ChocolateyGuiCli.csproj b/Source/ChocolateyGuiCli/ChocolateyGuiCli.csproj index af50b6c6b..db9cc3271 100644 --- a/Source/ChocolateyGuiCli/ChocolateyGuiCli.csproj +++ b/Source/ChocolateyGuiCli/ChocolateyGuiCli.csproj @@ -130,8 +130,15 @@ + + + + + BannedSymbols.txt + + \ No newline at end of file diff --git a/Source/ChocolateyGuiCli/packages.config b/Source/ChocolateyGuiCli/packages.config index 88aab42d2..177cea618 100644 --- a/Source/ChocolateyGuiCli/packages.config +++ b/Source/ChocolateyGuiCli/packages.config @@ -5,6 +5,7 @@ + From 834479daf8b22f1f935300533fe28ff912a76f80 Mon Sep 17 00:00:00 2001 From: AdmiringWorm Date: Fri, 2 Jun 2023 14:42:12 +0200 Subject: [PATCH 04/18] (#1005) Normalize version numbers This updates all displaying of version numbers and usages internally to ensure that the version numbers are normalized. This is the equivalent of changes made in Chocolatey CLI. --- .../ChocolateyGui.Common.Windows.csproj | 1 + .../Services/ChocolateyService.cs | 2 +- .../Converters/NuGetVersionToString.cs | 36 +++++++++++++++++++ .../ViewModels/AdvancedInstallViewModel.cs | 2 +- .../ViewModels/Items/PackageViewModel.cs | 14 ++++---- .../Views/LocalSourceView.xaml | 10 +++--- .../Views/PackageView.xaml | 3 +- .../Views/RemoteSourceView.xaml | 8 +++-- 8 files changed, 60 insertions(+), 16 deletions(-) create mode 100644 Source/ChocolateyGui.Common.Windows/Utilities/Converters/NuGetVersionToString.cs diff --git a/Source/ChocolateyGui.Common.Windows/ChocolateyGui.Common.Windows.csproj b/Source/ChocolateyGui.Common.Windows/ChocolateyGui.Common.Windows.csproj index cdbca143c..06cd8e13b 100644 --- a/Source/ChocolateyGui.Common.Windows/ChocolateyGui.Common.Windows.csproj +++ b/Source/ChocolateyGui.Common.Windows/ChocolateyGui.Common.Windows.csproj @@ -235,6 +235,7 @@ + diff --git a/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs b/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs index de9df8649..65835ae7c 100644 --- a/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs +++ b/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs @@ -195,7 +195,7 @@ public async Task InstallPackage( if (version != null) { - config.Version = version.ToString(); + config.Version = version; } if (source != null) diff --git a/Source/ChocolateyGui.Common.Windows/Utilities/Converters/NuGetVersionToString.cs b/Source/ChocolateyGui.Common.Windows/Utilities/Converters/NuGetVersionToString.cs new file mode 100644 index 000000000..ec26227c3 --- /dev/null +++ b/Source/ChocolateyGui.Common.Windows/Utilities/Converters/NuGetVersionToString.cs @@ -0,0 +1,36 @@ +namespace ChocolateyGui.Common.Windows.Utilities.Converters +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Linq; + using System.Text; + using System.Threading.Tasks; + using System.Windows; + using System.Windows.Data; + using chocolatey; + using NuGet.Versioning; + + public class NuGetVersionToString : DependencyObject, IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is NuGetVersion version) + { + return version.ToNormalizedStringChecked(); + } + + return value; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is string sValue && NuGetVersion.TryParse(sValue, out var version)) + { + return version; + } + + throw new InvalidOperationException("The passed in value is not a parseable string version!"); + } + } +} diff --git a/Source/ChocolateyGui.Common.Windows/ViewModels/AdvancedInstallViewModel.cs b/Source/ChocolateyGui.Common.Windows/ViewModels/AdvancedInstallViewModel.cs index 524a88e14..c6cabffc1 100644 --- a/Source/ChocolateyGui.Common.Windows/ViewModels/AdvancedInstallViewModel.cs +++ b/Source/ChocolateyGui.Common.Windows/ViewModels/AdvancedInstallViewModel.cs @@ -66,7 +66,7 @@ public AdvancedInstallViewModel( _cts = new CancellationTokenSource(); - _packageVersion = packageVersion.ToString(); + _packageVersion = packageVersion.ToNormalizedStringChecked(); SelectedVersion = _packageVersion; FetchAvailableVersions(); diff --git a/Source/ChocolateyGui.Common.Windows/ViewModels/Items/PackageViewModel.cs b/Source/ChocolateyGui.Common.Windows/ViewModels/Items/PackageViewModel.cs index 61218a17e..2070d1668 100644 --- a/Source/ChocolateyGui.Common.Windows/ViewModels/Items/PackageViewModel.cs +++ b/Source/ChocolateyGui.Common.Windows/ViewModels/Items/PackageViewModel.cs @@ -11,6 +11,7 @@ using System.Threading.Tasks; using AutoMapper; using Caliburn.Micro; +using chocolatey; using ChocolateyGui.Common.Base; using ChocolateyGui.Common.Models; using ChocolateyGui.Common.Models.Messages; @@ -405,7 +406,8 @@ public bool IsPackageSizeAvailable public async Task ShowArguments() { - var decryptedArguments = _packageArgumentsService.DecryptPackageArgumentsFile(Id, Version.ToString()).ToList(); + // TODO: Add legacy handling for packages installed prior to v2.0.0. + var decryptedArguments = _packageArgumentsService.DecryptPackageArgumentsFile(Id, Version.ToNormalizedStringChecked()).ToList(); if (decryptedArguments.Count == 0) { @@ -423,7 +425,7 @@ await _dialogService.ShowMessageAsync( public async Task Install() { - await InstallPackage(Version.ToString()); + await InstallPackage(Version.ToNormalizedStringChecked()); } public async Task InstallAdvanced() @@ -465,7 +467,7 @@ public async Task Reinstall() { using (await StartProgressDialog(L(nameof(Resources.PackageViewModel_ReinstallingPackage)), L(nameof(Resources.PackageViewModel_ReinstallingPackage)), Id)) { - await _chocolateyService.InstallPackage(Id, Version.ToString(), Source, true); + await _chocolateyService.InstallPackage(Id, Version.ToNormalizedStringChecked(), Source, true); _chocolateyGuiCacheService.PurgeOutdatedPackages(); await _eventAggregator.PublishOnUIThreadAsync(new PackageChangedMessage(Id, PackageChangeType.Installed, Version)); } @@ -496,7 +498,7 @@ public async Task Uninstall() { using (await StartProgressDialog(L(nameof(Resources.PackageViewModel_UninstallingPackage)), L(nameof(Resources.PackageViewModel_UninstallingPackage)), Id)) { - var result = await _chocolateyService.UninstallPackage(Id, Version.ToString(), true); + var result = await _chocolateyService.UninstallPackage(Id, Version.ToNormalizedStringChecked(), true); if (!result.Successful) { @@ -584,7 +586,7 @@ public async Task Pin() { using (await StartProgressDialog(L(nameof(Resources.PackageViewModel_PinningPackage)), L(nameof(Resources.PackageViewModel_PinningPackage)), Id)) { - var result = await _chocolateyService.PinPackage(Id, Version.ToString()); + var result = await _chocolateyService.PinPackage(Id, Version.ToNormalizedStringChecked()); if (!result.Successful) { @@ -628,7 +630,7 @@ public async Task Unpin() { using (await StartProgressDialog(L(nameof(Resources.PackageViewModel_UnpinningPackage)), L(nameof(Resources.PackageViewModel_UnpinningPackage)), Id)) { - var result = await _chocolateyService.UnpinPackage(Id, Version.ToString()); + var result = await _chocolateyService.UnpinPackage(Id, Version.ToNormalizedStringChecked()); if (!result.Successful) { diff --git a/Source/ChocolateyGui.Common.Windows/Views/LocalSourceView.xaml b/Source/ChocolateyGui.Common.Windows/Views/LocalSourceView.xaml index 3c3b0736d..6e532a798 100644 --- a/Source/ChocolateyGui.Common.Windows/Views/LocalSourceView.xaml +++ b/Source/ChocolateyGui.Common.Windows/Views/LocalSourceView.xaml @@ -14,12 +14,14 @@ xmlns:commands="clr-namespace:ChocolateyGui.Common.Windows.Commands" xmlns:controls="clr-namespace:ChocolateyGui.Common.Windows.Controls" xmlns:theming="clr-namespace:ChocolateyGui.Common.Windows.Theming" + xmlns:converters="clr-namespace:ChocolateyGui.Common.Windows.Utilities.Converters" mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="1366" - d:DataContext="{d:DesignInstance viewModels:LocalSourceViewModel}" + d:DataContext="{d:DesignInstance {x:Type viewModels:LocalSourceViewModel}}" Background="{DynamicResource MahApps.Brushes.ThemeBackground}"> + @@ -59,12 +61,12 @@ + Text="{Binding LatestVersion, Converter={StaticResource NuGetVersionToString}, Mode=OneWay}" /> + Text="{Binding Version, Converter={StaticResource NuGetVersionToString}, Mode=OneWay}" /> + @@ -196,7 +197,7 @@ @@ -270,7 +272,7 @@ + Text="{Binding Version, Converter={StaticResource NuGetVersionToString}, Mode=OneWay}" /> Date: Wed, 7 Jun 2023 15:09:15 +0200 Subject: [PATCH 05/18] (#1003) Handle null keys during source translation The helper class that is used whe looking up any translations that has been made did not handle the translation source strings when they are null or empty. This causes problems when especially looking up description of Chocolatey settings items that by some reason did not have a description associated with themself in the configuration file. --- .../Utilities/TranslationSource.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/ChocolateyGui.Common/Utilities/TranslationSource.cs b/Source/ChocolateyGui.Common/Utilities/TranslationSource.cs index f95a01005..f8bff5fd1 100644 --- a/Source/ChocolateyGui.Common/Utilities/TranslationSource.cs +++ b/Source/ChocolateyGui.Common/Utilities/TranslationSource.cs @@ -1,4 +1,4 @@ -// -------------------------------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- // // Copyright 2017 - Present Chocolatey Software, LLC // Copyright 2014 - 2017 Rob Reynolds, the maintainers of Chocolatey, and RealDimensions Software, LLC @@ -47,6 +47,14 @@ public string this[string key] { get { + if (string.IsNullOrEmpty(key)) + { + // If the key is null we can't pass it to the resource manager. + // As it also doesn't make sense to pass in an empty value we check for both. + // We pass this empty string as we don't want anything to break even on empty values. + return string.Empty; + } + var value = _resourceManager.GetString(key, CurrentCulture); #if DEBUG if (string.IsNullOrEmpty(value) && !string.IsNullOrEmpty(key)) From 57ddd10186943e98fb5c45994674da61bd7f9169 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Thu, 8 Jun 2023 10:41:41 +0100 Subject: [PATCH 06/18] (maint) Update to released alpha package This includes a bump in the dependency in the nuspec to point at the newly released alpha package for Chocolatey CLI itself. --- .../ChocolateyGui.Common.Windows.csproj | 2 +- Source/ChocolateyGui.Common.Windows/packages.config | 2 +- Source/ChocolateyGui.Common/ChocolateyGui.Common.csproj | 2 +- Source/ChocolateyGui.Common/packages.config | 2 +- Source/ChocolateyGui/ChocolateyGui.csproj | 2 +- Source/ChocolateyGui/packages.config | 2 +- Source/ChocolateyGuiCli/ChocolateyGuiCli.csproj | 2 +- Source/ChocolateyGuiCli/packages.config | 2 +- nuspec/chocolatey/ChocolateyGUI.nuspec | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/ChocolateyGui.Common.Windows/ChocolateyGui.Common.Windows.csproj b/Source/ChocolateyGui.Common.Windows/ChocolateyGui.Common.Windows.csproj index 06cd8e13b..81e957209 100644 --- a/Source/ChocolateyGui.Common.Windows/ChocolateyGui.Common.Windows.csproj +++ b/Source/ChocolateyGui.Common.Windows/ChocolateyGui.Common.Windows.csproj @@ -68,7 +68,7 @@ ..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.Core.dll - ..\packages\chocolatey.lib.2.1.0-alpha-20230605-1278\lib\net48\chocolatey.dll + ..\packages\chocolatey.lib.2.1.0-alpha-20230608\lib\net48\chocolatey.dll False False diff --git a/Source/ChocolateyGui.Common.Windows/packages.config b/Source/ChocolateyGui.Common.Windows/packages.config index 30ad803ef..cbffb00a1 100644 --- a/Source/ChocolateyGui.Common.Windows/packages.config +++ b/Source/ChocolateyGui.Common.Windows/packages.config @@ -5,7 +5,7 @@ - + diff --git a/Source/ChocolateyGui.Common/ChocolateyGui.Common.csproj b/Source/ChocolateyGui.Common/ChocolateyGui.Common.csproj index 8e077a25a..7172caddd 100644 --- a/Source/ChocolateyGui.Common/ChocolateyGui.Common.csproj +++ b/Source/ChocolateyGui.Common/ChocolateyGui.Common.csproj @@ -55,7 +55,7 @@ ..\packages\AutoMapper.7.0.1\lib\net45\AutoMapper.dll - ..\packages\chocolatey.lib.2.1.0-alpha-20230605-1278\lib\net48\chocolatey.dll + ..\packages\chocolatey.lib.2.1.0-alpha-20230608\lib\net48\chocolatey.dll False False diff --git a/Source/ChocolateyGui.Common/packages.config b/Source/ChocolateyGui.Common/packages.config index f14a3eda7..4aa1a7130 100644 --- a/Source/ChocolateyGui.Common/packages.config +++ b/Source/ChocolateyGui.Common/packages.config @@ -3,7 +3,7 @@ - + diff --git a/Source/ChocolateyGui/ChocolateyGui.csproj b/Source/ChocolateyGui/ChocolateyGui.csproj index fa4ffbe7f..850b507a1 100644 --- a/Source/ChocolateyGui/ChocolateyGui.csproj +++ b/Source/ChocolateyGui/ChocolateyGui.csproj @@ -114,7 +114,7 @@ ..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.Core.dll - ..\packages\chocolatey.lib.2.1.0-alpha-20230605-1278\lib\net48\chocolatey.dll + ..\packages\chocolatey.lib.2.1.0-alpha-20230608\lib\net48\chocolatey.dll False False diff --git a/Source/ChocolateyGui/packages.config b/Source/ChocolateyGui/packages.config index c2ddf56d5..dc73a0a52 100644 --- a/Source/ChocolateyGui/packages.config +++ b/Source/ChocolateyGui/packages.config @@ -5,7 +5,7 @@ - + diff --git a/Source/ChocolateyGuiCli/ChocolateyGuiCli.csproj b/Source/ChocolateyGuiCli/ChocolateyGuiCli.csproj index db9cc3271..bbea11a81 100644 --- a/Source/ChocolateyGuiCli/ChocolateyGuiCli.csproj +++ b/Source/ChocolateyGuiCli/ChocolateyGuiCli.csproj @@ -57,7 +57,7 @@ ..\packages\Autofac.4.6.1\lib\net45\Autofac.dll - ..\packages\chocolatey.lib.2.1.0-alpha-20230605-1278\lib\net48\chocolatey.dll + ..\packages\chocolatey.lib.2.1.0-alpha-20230608\lib\net48\chocolatey.dll False False diff --git a/Source/ChocolateyGuiCli/packages.config b/Source/ChocolateyGuiCli/packages.config index 177cea618..bbc972973 100644 --- a/Source/ChocolateyGuiCli/packages.config +++ b/Source/ChocolateyGuiCli/packages.config @@ -2,7 +2,7 @@ - + diff --git a/nuspec/chocolatey/ChocolateyGUI.nuspec b/nuspec/chocolatey/ChocolateyGUI.nuspec index 606a90b15..820a97d6c 100644 --- a/nuspec/chocolatey/ChocolateyGUI.nuspec +++ b/nuspec/chocolatey/ChocolateyGUI.nuspec @@ -27,7 +27,7 @@ All release notes for Chocolatey GUI can be found on the docs site - https://doc chocolateygui chocolatey admin foss - + From 7a3a78257d618098f6d2e32336d364bd9acc2851 Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH Date: Fri, 27 Jan 2023 20:32:15 -0600 Subject: [PATCH 07/18] (#980) Use assembly location when debugging This sets the Chocolatey install directory to the current assembly directory when built as a debug build. This allows correctly getting the location of remembered arguments from the debug installed package(s) instead of from the systemwide install of Chocolatey. If a debug build is in use, then Chocolatey GUI is using the chocolatey lib assembly, so true can be returned in all cases. --- .../Providers/ChocolateyConfigurationProvider.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/ChocolateyGui.Common/Providers/ChocolateyConfigurationProvider.cs b/Source/ChocolateyGui.Common/Providers/ChocolateyConfigurationProvider.cs index ea5cd36f0..294a53431 100644 --- a/Source/ChocolateyGui.Common/Providers/ChocolateyConfigurationProvider.cs +++ b/Source/ChocolateyGui.Common/Providers/ChocolateyConfigurationProvider.cs @@ -29,6 +29,9 @@ public ChocolateyConfigurationProvider(IFileSystem fileSystem) private void GetChocolateyInstallLocation() { +#if DEBUG + ChocolateyInstall = _fileSystem.GetDirectoryName(_fileSystem.GetCurrentAssemblyPath()); +#else ChocolateyInstall = Environment.GetEnvironmentVariable("ChocolateyInstall"); if (string.IsNullOrWhiteSpace(ChocolateyInstall)) { @@ -46,16 +49,21 @@ private void GetChocolateyInstallLocation() { ChocolateyInstall = string.Empty; } +#endif } private void DetermineIfChocolateyExecutableIsBeingUsed() { +#if DEBUG + IsChocolateyExecutableBeingUsed = true; +#else var exePath = _fileSystem.CombinePaths(ChocolateyInstall, "choco.exe"); if (_fileSystem.FileExists(exePath)) { IsChocolateyExecutableBeingUsed = true; } +#endif } } } \ No newline at end of file From e3fcea67b0e403427d706e42cddd00b979a44378 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Fri, 9 Jun 2023 10:38:26 +0100 Subject: [PATCH 08/18] (maint) Fix StyleCop warnings --- .../Utilities/Converters/NuGetVersionToString.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/ChocolateyGui.Common.Windows/Utilities/Converters/NuGetVersionToString.cs b/Source/ChocolateyGui.Common.Windows/Utilities/Converters/NuGetVersionToString.cs index ec26227c3..8137dda5e 100644 --- a/Source/ChocolateyGui.Common.Windows/Utilities/Converters/NuGetVersionToString.cs +++ b/Source/ChocolateyGui.Common.Windows/Utilities/Converters/NuGetVersionToString.cs @@ -1,4 +1,11 @@ -namespace ChocolateyGui.Common.Windows.Utilities.Converters +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright 2017 - Present Chocolatey Software, LLC +// Copyright 2014 - 2017 Rob Reynolds, the maintainers of Chocolatey, and RealDimensions Software, LLC +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ChocolateyGui.Common.Windows.Utilities.Converters { using System; using System.Collections.Generic; @@ -33,4 +40,4 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu throw new InvalidOperationException("The passed in value is not a parseable string version!"); } } -} +} \ No newline at end of file From 35e99da7b27a2cb5afacb65b43b0e2b8dcc788ea Mon Sep 17 00:00:00 2001 From: Josh King Date: Mon, 17 Apr 2023 15:02:15 +1200 Subject: [PATCH 09/18] (#993) Add TC schedule trigger Adds the TeamCity schedule trigger feature and adjusts the Call Cake build step to adjust the testExecutionType based on how the build was triggered. Also removes the version statement which is not needed. --- .teamcity/settings.kts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.teamcity/settings.kts b/.teamcity/settings.kts index 990e59465..6001db35a 100644 --- a/.teamcity/settings.kts +++ b/.teamcity/settings.kts @@ -3,10 +3,9 @@ import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.script import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.powerShell import jetbrains.buildServer.configs.kotlin.v2019_2.buildFeatures.pullRequests import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.vcs +import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.schedule import jetbrains.buildServer.configs.kotlin.v2019_2.vcs.GitVcsRoot -version = "2021.2" - project { buildType(ChocolateyGUI) } @@ -62,7 +61,10 @@ object ChocolateyGUI : BuildType({ script { name = "Call Cake" - scriptContent = "call build.official.bat" + scriptContent = scriptContent = """ + IF "%teamcity.build.triggeredBy%" == "Schedule Trigger" (SET TestType=all) ELSE (SET TestType=unit) + call build.official.bat --verbosity=diagnostic --target=CI --testExecutionType=%%TestType%% --shouldRunOpenCover=false + """.trimIndent() } } @@ -70,6 +72,17 @@ object ChocolateyGUI : BuildType({ vcs { branchFilter = "" } + schedule { + schedulingPolicy = daily { + hour = 2 + minute = 0 + } + branchFilter = """ + +: + """.trimIndent() + triggerBuild = always() + withPendingChangesOnly = false + } } features { From 98cc1ac71064ac0f38e0d12bdaa68a6039438639 Mon Sep 17 00:00:00 2001 From: Josh King Date: Mon, 12 Jun 2023 09:33:46 +1200 Subject: [PATCH 10/18] (#993) (fix) Correct syntax in KTS file --- .teamcity/settings.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.teamcity/settings.kts b/.teamcity/settings.kts index 6001db35a..c734b6517 100644 --- a/.teamcity/settings.kts +++ b/.teamcity/settings.kts @@ -61,7 +61,7 @@ object ChocolateyGUI : BuildType({ script { name = "Call Cake" - scriptContent = scriptContent = """ + scriptContent = """ IF "%teamcity.build.triggeredBy%" == "Schedule Trigger" (SET TestType=all) ELSE (SET TestType=unit) call build.official.bat --verbosity=diagnostic --target=CI --testExecutionType=%%TestType%% --shouldRunOpenCover=false """.trimIndent() From 99b1a837d3eb6e3a01f4e643e0e824efa89ed44b Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Mon, 12 Jun 2023 07:21:40 +0100 Subject: [PATCH 11/18] (build) Make build files consistent with others The build entry scripts in this repository are slightly different to the other repositories that we have, and there is no good reason for them to be different. This commits adds the .bat files from chocolatey/choco repository so that they are consistent, and there aren't any surprises between how builds are executed. --- build.bat | 7 +++---- build.debug.bat | 7 +++---- build.official.bat | 9 ++++----- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/build.bat b/build.bat index 23f932eaa..b798ba2d4 100644 --- a/build.bat +++ b/build.bat @@ -1,12 +1,11 @@ @echo off -setlocal enableextensions enabledelayedexpansion -set psscript="./build.ps1" +set psscript="%~dp0build.ps1" echo ================================================== echo ============= WRAP POWERSHELL SCRIPT ============= echo ================================================== echo calling %psscript% with args %* PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%psscript%' %*" - +set buildstatus=%ERRORLEVEL% echo ================================================== -endlocal +exit /b %buildstatus% \ No newline at end of file diff --git a/build.debug.bat b/build.debug.bat index d657e4a4d..417cf087b 100644 --- a/build.debug.bat +++ b/build.debug.bat @@ -1,12 +1,11 @@ @echo off -setlocal enableextensions enabledelayedexpansion -set psscript="./build.ps1" +set psscript="%~dp0build.ps1" echo ================================================== echo ============= WRAP POWERSHELL SCRIPT ============= echo ================================================== echo calling %psscript% with args %* PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%psscript%' -Configuration Debug %*" - +set buildstatus=%ERRORLEVEL% echo ================================================== -endlocal +exit /b %buildstatus% diff --git a/build.official.bat b/build.official.bat index c66ad7466..66bad5bb0 100644 --- a/build.official.bat +++ b/build.official.bat @@ -1,12 +1,11 @@ @echo off -setlocal enableextensions enabledelayedexpansion -set psscript="./build.ps1" +set psscript="%~dp0build.ps1" echo ================================================== echo ============= WRAP POWERSHELL SCRIPT ============= echo ================================================== echo calling %psscript% with args %* -PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%psscript%' -Configuration ReleaseOfficial -Target CI %*" - +PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%psscript%' -Configuration ReleaseOfficial %*" +set buildstatus=%ERRORLEVEL% echo ================================================== -endlocal +exit /b %buildstatus% From 44bd3418aa6af9bfa805ed101cfc929fb58a1e67 Mon Sep 17 00:00:00 2001 From: AdmiringWorm Date: Wed, 14 Jun 2023 15:50:49 +0200 Subject: [PATCH 12/18] (#1014) Ignore cached files on forced outdated check This changes how the outdated command works. When the user forces an outdated check to happen it will bypass any cached http resources that Chocolatey CLI has created. This allows a user to get the absolute latest information even when the automatic outdated check does not update outside of cached items until they have expired. --- .../Services/ChocolateyService.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs b/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs index 65835ae7c..b0efa34fb 100644 --- a/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs +++ b/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs @@ -132,6 +132,11 @@ public async Task> GetOutdatedPackages(bool inclu config.RegularOutput = false; config.QuietOutput = true; config.Prerelease = false; + + if (forceCheckForOutdatedPackages) + { + config.CacheExpirationInMinutes = 0; + } }); var chocoConfig = choco.GetConfiguration(); From c1aa875ff7518a8410db09fbb761adc68baa6881 Mon Sep 17 00:00:00 2001 From: AdmiringWorm Date: Wed, 14 Jun 2023 15:53:34 +0200 Subject: [PATCH 13/18] (#1014) Add advanced option to ignore cached items This adds a new option to the advanced installation dialog to be able to ignore any cached http resources that Chocolatey CLI has cached. This can be useful for sources that allows an existing version on the source can be replace, and then allow Chocolatey GUI to download the absolute latest version of the package. --- .../Services/ChocolateyService.cs | 7 ++- .../ViewModels/AdvancedInstallViewModel.cs | 12 ++++ .../Views/AdvancedInstallView.xaml | 4 ++ .../ChocolateyConfigurationExtensions.cs | 34 ++++++++++ .../ChocolateyGui.Common.csproj | 1 + .../Models/AdvancedInstall.cs | 2 + .../Properties/Resources.Designer.cs | 22 ++++++- .../Properties/Resources.resx | 62 ++++++++++--------- 8 files changed, 113 insertions(+), 31 deletions(-) create mode 100644 Source/ChocolateyGui.Common/ChocolateyConfigurationExtensions.cs diff --git a/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs b/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs index b0efa34fb..f4b54b689 100644 --- a/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs +++ b/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs @@ -135,7 +135,7 @@ public async Task> GetOutdatedPackages(bool inclu if (forceCheckForOutdatedPackages) { - config.CacheExpirationInMinutes = 0; + config.SetCacheExpirationInMinutes(0); } }); var chocoConfig = choco.GetConfiguration(); @@ -253,6 +253,11 @@ public async Task InstallPackage( config.DownloadChecksum64 = advancedInstallOptions.DownloadChecksum64bit; config.DownloadChecksumType = advancedInstallOptions.DownloadChecksumType; config.DownloadChecksumType64 = advancedInstallOptions.DownloadChecksumType64bit; + + if (advancedInstallOptions.IgnoreHTTPCache) + { + config.SetCacheExpirationInMinutes(0); + } } }); diff --git a/Source/ChocolateyGui.Common.Windows/ViewModels/AdvancedInstallViewModel.cs b/Source/ChocolateyGui.Common.Windows/ViewModels/AdvancedInstallViewModel.cs index c6cabffc1..30d1923a2 100644 --- a/Source/ChocolateyGui.Common.Windows/ViewModels/AdvancedInstallViewModel.cs +++ b/Source/ChocolateyGui.Common.Windows/ViewModels/AdvancedInstallViewModel.cs @@ -42,6 +42,7 @@ public class AdvancedInstallViewModel : ObservableBase, IClosableChildWindow + 0 0 @@ -247,6 +248,9 @@