From 49f2d2c2ef6ee4c346c8ba9e61127620a15de383 Mon Sep 17 00:00:00 2001 From: Manikyam Bavandla Date: Mon, 24 Sep 2018 12:02:52 -0700 Subject: [PATCH] Fix CommandAlreadyAvailable error for PackageManagement module. This is happening as Get-Command returns the local commands from PSModule.psm1 for the Find-Package, Install-Package and Uninstall-Package provider functions. Added check to ignore the commands from PSModule.psm1. Resolves #329 --- CHANGELOG.md | 3 ++- PowerShellGet/PowerShellGet.psd1 | 3 ++- .../functions/Validate-ModuleCommandAlreadyAvailable.ps1 | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fee2c2c2..20f40056 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # Changelog ## 2.0.1 -Bug fix +Bug fixes - Resolved Publish-Module doesn't report error but fails to publish module (#316) +- Resolved CommandAlreadyAvailable error while installing the latest version of PackageManagement module (#333) ## 2.0.0 Breaking Change diff --git a/PowerShellGet/PowerShellGet.psd1 b/PowerShellGet/PowerShellGet.psd1 index e8bad743..38a48250 100644 --- a/PowerShellGet/PowerShellGet.psd1 +++ b/PowerShellGet/PowerShellGet.psd1 @@ -55,8 +55,9 @@ PrivateData = @{ LicenseUri = 'https://go.microsoft.com/fwlink/?LinkId=829061' ReleaseNotes = @' ## 2.0.1 -Bug fix +Bug fixes - Resolved Publish-Module doesn't report error but fails to publish module (#316) +- Resolved CommandAlreadyAvailable error while installing the latest version of PackageManagement module (#333) ## 2.0.0 diff --git a/PowerShellGet/private/functions/Validate-ModuleCommandAlreadyAvailable.ps1 b/PowerShellGet/private/functions/Validate-ModuleCommandAlreadyAvailable.ps1 index 2f153ed5..4e5ae0f1 100644 --- a/PowerShellGet/private/functions/Validate-ModuleCommandAlreadyAvailable.ps1 +++ b/PowerShellGet/private/functions/Validate-ModuleCommandAlreadyAvailable.ps1 @@ -56,6 +56,7 @@ function Validate-ModuleCommandAlreadyAvailable -WarningAction SilentlyContinue | Microsoft.PowerShell.Core\Where-Object { ($CommandNames -contains $_.Name) -and ($_.ModuleName -ne $script:PSModuleProviderName) -and + ($_.ModuleName -ne 'PSModule') -and ($_.ModuleName -ne $CurrentModuleInfo.Name) } if($AvailableCommands) {