PowerShell / PSResourceGet

PSResourceGet is the package manager for PowerShell
https://www.powershellgallery.com/packages/Microsoft.PowerShell.PSResourceGet
MIT License
490 stars 94 forks source link

Uninstall-PSResource uninstalls module when some other module depends on it #1303

Closed adityapatwardhan closed 1 year ago

adityapatwardhan commented 1 year ago

Prerequisites

Steps to reproduce

Install Az.Storage module. It depends on Az.Accounts. Then try to uninstall Az.Accounts.

Find-PSResource -Name pester,az.storage -IncludeDependencies -Verbose
VERBOSE: Searching in repository PSGallery

Name        Version Prerelease Repository Description
----        ------- ---------- ---------- -----------
Pester      5.5.0              PSGallery  Pester provides a framework for running BDD style Tests to execute and validate PowerShell commands inside of PowerShel…
Az.Storage  5.8.0              PSGallery  Microsoft Azure PowerShell - Storage service data plane and management cmdlets for Azure Resource Manager in Windows Po…
Az.Accounts 2.12.4             PSGallery  Microsoft Azure PowerShell - Accounts credential management cmdlets for Azure Resource Manager in Windows PowerShell an…

Install-PSResource -Name az.accounts,pester,az.storage -Verbose

Uninstall-PSResource -Name az.accounts -Verbose

Uninstall-PSResource -Name az.accounts -Verbose should not uninstall the Az.Accounts module.

Expected behavior

Az.Accounts module should not be removed

Actual behavior

Uninstall-PSResource -Name az.accounts -Verbose
VERBOSE: Retrieving directories in the path '/home/aditya/.local/share/powershell/Modules'
VERBOSE: Retrieving directories in the path '/home/aditya/.local/share/powershell/Scripts'
VERBOSE: All paths to search: '/home/aditya/.local/share/powershell/Modules/Az.Storage'
VERBOSE: All paths to search: '/home/aditya/.local/share/powershell/Modules/Az.Accounts'
VERBOSE: All paths to search: '/home/aditya/.local/share/powershell/Modules/Pester'
VERBOSE: All paths to search: '/home/aditya/.local/share/powershell/Modules/Microsoft.PowerShell.PSResourceGet'
VERBOSE: Searching through package path: '/home/aditya/.local/share/powershell/Modules/Az.Accounts'
VERBOSE: Searching through package path: '/home/aditya/.local/share/powershell/Modules/Az.Accounts'
VERBOSE: Searching through package version path: '/home/aditya/.local/share/powershell/Modules/Az.Accounts/2.12.4'
VERBOSE: Package version parsed as NuGet version: '2.12.4'
VERBOSE: Performing the operation "Uninstall-PSResource" on target "Uninstall resource 'Az.Accounts', version '2.12.4', from path '/home/aditya/.local/share/powershell/Modules/Az.Accounts/2.12.4'".
VERBOSE: Successfully uninstalled 'Az.Accounts' from path '/home/aditya/.local/share/powershell/Modules/Az.Accounts/2.12.4'.

Error details

No error when error is expected

Environment data

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Binary     0.5.23     beta23     Microsoft.PowerShell.PSResourceGet  {Find-PSResource, Get-InstalledPSResource, Get-PSResourceRepository, Get-PSScriptFileInfo…}

Name                           Value
----                           -----
PSVersion                      7.3.4
PSEdition                      Core
GitCommitId                    7.3.4
OS                             Linux 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

SimonWahlin commented 1 year ago

I think this is a duplicate of #760