PSResourceGet
PSResourceGet copied to clipboard
3.0.16-beta | Update-PSResource reinstalls modules installed by pre v3 PowerShellGet, even though there is no new version
Prerequisites
- [X] Write a descriptive title.
- [X] Make sure you are able to repro it on the latest released version
- [X] Search the existing issues.
Steps to reproduce
See #619 as it's not fixed.
- https://github.com/PowerShell/PowerShellGet/issues/619#issuecomment-1201500377
Expected behavior
See #619 as it's not fixed.
Actual behavior
See #619 as it's not fixed.
Error details
No response
Environment data
See #619 as it's not fixed.
Visuals
No response
I just confirmed that this issue persists with beta 17, but seems like the project already knows that. :)
Slightly updated PowerShell code to reproduce
#Requires -RunAsAdministrator
<#
.SYNOPSIS
Test PowerShellGet v3 beta 17.
.NOTES
Author: Olav Rønnestad Birkeland | github.com/o-l-a-v
Created: 220801
Modified: 220801
Related GitHub issue:
* https://github.com/PowerShell/PowerShellGet/issues/619
* https://github.com/PowerShell/PowerShellGet/issues/749
#>
# Assets
$ModuleName = [string] 'SetBIOS'
# Old PowerShellGet
## Remove conflicting modules
Remove-Module -Name 'PackageManagement','PowerShellGet','PSReadline' -Force -ErrorAction 'SilentlyContinue'
## Import relevant module
Import-Module -Name 'PowerShellGet' -RequiredVersion '2.2.5'; Get-Module
## Uninstall $ModuleName if present
if ($([array](Get-Module -ListAvailable -Name $ModuleName)).'Count' -gt 0) {Uninstall-Module -Name $ModuleName -AllVersions}
## Install $ModuleName with PowerShellGet v2.2.5
Install-Module -Name $ModuleName -Scope 'AllUsers' -Repository 'PSGallery' -Force
## Check if PowerShellGet v2.2.5 will update it.
## It righfully returns that no update is available.
Update-Module -Name $ModuleName -Scope 'AllUsers' -Verbose
# New PowerShellGet
## Remove conflicting modules
Remove-Module -Name 'PackageManagement','PowerShellGet','PSReadline' -Force -ErrorAction 'SilentlyContinue'
## Import PowerShellGet v3.0.17-beta
Import-Module -Name ('{0}\powershellget.3.0.17-beta17\PowerShellGet.psd1' -f [System.Environment]::GetFolderPath('Desktop')); Get-Module
## Check if PowerShellGet v3.0.17-beta will update the module in question, once.
## Installs $ModuleName, same versions that are already installed.
Update-PSResource -Name $ModuleName -Scope 'AllUsers' -Repository 'PSGallery' -TrustRepository -Verbose
## Check if PowerShellGet v3.0.17-beta will update the module in question, 2nd time.
## It says $ModuleName is up to date.
Update-PSResource -Name $ModuleName -Scope 'AllUsers' -Repository 'PSGallery' -TrustRepository -Verbose
## Uninstall, because after PowerShellGet v3 installed it, PowerShellGet v2 can't see it or remove it
Uninstall-PSResource -Name $ModuleName -Scope 'AllUsers' -Verbose