From 875f27fb6714b9cdf06462e41d683b409c1e8884 Mon Sep 17 00:00:00 2001 From: metablaster <44481081+metablaster@users.noreply.github.com> Date: Sun, 18 Jun 2023 15:04:59 +0200 Subject: [PATCH] Fix NuGet initialization in Windows PS --- Modules/Ruleset.Initialize/Public/Initialize-Provider.ps1 | 6 +++++- .../Ruleset.Initialize/Public/Uninstall-DuplicateModule.ps1 | 4 ++-- docs/CHANGELOG.md | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Modules/Ruleset.Initialize/Public/Initialize-Provider.ps1 b/Modules/Ruleset.Initialize/Public/Initialize-Provider.ps1 index 87e092e3..6264d66b 100644 --- a/Modules/Ruleset.Initialize/Public/Initialize-Provider.ps1 +++ b/Modules/Ruleset.Initialize/Public/Initialize-Provider.ps1 @@ -409,7 +409,11 @@ function Initialize-Provider # It may also be the case if a user denied registering a package source. if (!$FoundPackageSource -or ($FoundPackageSource.ProviderName -notin (Get-PackageSource).ProviderName)) { - Write-Warning -Message "[$($MyInvocation.InvocationName)] Not using '$($FoundPackageSource.ProviderName)' provider to install package, package source not registered" + # Else warning was diplayed by Get-PackageSource + if ($FoundPackageSource) + { + Write-Warning -Message "[$($MyInvocation.InvocationName)] Not using '$($FoundPackageSource.ProviderName)' provider to install package, package source not registered" + } # TODO: This scenario needs testing, it currently works for NuGet in Windows PowerShell return $null -ne (Get-PackageProvider -Name $ProviderName) diff --git a/Modules/Ruleset.Initialize/Public/Uninstall-DuplicateModule.ps1 b/Modules/Ruleset.Initialize/Public/Uninstall-DuplicateModule.ps1 index 9660b9f0..50ae4b8b 100644 --- a/Modules/Ruleset.Initialize/Public/Uninstall-DuplicateModule.ps1 +++ b/Modules/Ruleset.Initialize/Public/Uninstall-DuplicateModule.ps1 @@ -207,7 +207,7 @@ function Uninstall-DuplicateModule } catch { - Write-Warning -Message "[$($MyInvocation.InvocationName)] Please close down all other PowerShell sessions including VSCode, then try again" + Write-Warning -Message "[$($MyInvocation.InvocationName)] Please close down all PowerShell sessions including VSCode, then try again in fresh console" Write-Error -Category ResourceBusy -TargetObject $LoadedModule ` -Message "Module '$ModuleName' could not be removed from current PS session which is required for uninstallation because: $($_.Exception.Message)" @@ -244,7 +244,7 @@ function Uninstall-DuplicateModule } else { - Write-Warning -Message "[$($MyInvocation.InvocationName)] please close down all other PowerShell sessions including VSCode, then try again" + Write-Warning -Message "[$($MyInvocation.InvocationName)] please close down other PowerShell sessions including VSCode, then try again in fresh console" } Write-Error -Category OperationStopped -TargetObject $ModuleRoot ` diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 7322f3a0..499e00bd 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -43,6 +43,8 @@ Here is a list of changes for each of the releases. - `Get-SystemSoftware` renamed to `Get-SystemProgram` - `Get-UserSoftware` renamed to `Get-UserProgram` - `Get-SystemProgram` Improved program search + - `Uninstall-DuplicateModule` Improved to show reason for failure and how to fix + - `Initialize-Provider` Was failing in Windows PS on Windows 11, fixed - Scripts