You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 13, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Jun 13, 2024. It is now read-only.
Unable to Install-Module 'PowerShellGet' from an Azure DevOps build pipeline #663
So I'm running a build pipeline in Azure DevOps and one of the steps requires to install various packages, some from PSGallery and some from an internal feed. In order to do that the first thing I do is:
After that I should be able to install the remaining packages.
The problem is that sometimes, PowerShellGet updates and sometimes it doesn't. Which makes it a pain to debug and determine what works and what doesn't.
I know a bug report should have a deterministic repro step process, but I don't have one. Sometimes it fails and sometimes it doesn't.
I have seen this fail in the past and I've resolved it by simply opening a new PowerShell instance, but that's not possible (Or at least I don't know how to do it) in an Azure DevOps build pipeline.
Jose Antonio (@santanor) thanks for outlining your issue here! Would you be able to provide a little more information on the environment you are using? Specifically, the version of PowerShell, you can run $PSVersionTable and paste the output here just for our reference.
Also do you mind running Install-Module 'PowerShellGet' -AllowClobber -RequiredVersion "2.2.5" -Force -Repository 'PSGallery' -SkipPublisherCheck -Debug -Verbose
and including the output.
Is there a particular reason you need to install PackageManagement 1.4.3? You also do not need to install PackageManagemnt because PowerShellGet installs it. This might be causing your issue because you are installing a lower version of PackageManagement than what is required on PowerShellGet (PackageManagment 1.4.7).
Is there a particular reason you need to install PackageManagement 1.4.3?
I'm not sure, I inherited this script so I'm cautious about making changes. Didn't know I didn't need it.
So I removed the explicit installation of PackageManagement and tried to run only Install-Module 'PowerShellGet' -AllowClobber -RequiredVersion "2.2.5" -Force -Repository 'PSGallery' -SkipPublisherCheck -Debug -Verbose
It failed with the following output (Sorry, it's quite long)
'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PowerShellGet'&$skip=80&$top=40'.
DEBUG: 00:00:00.7365119 Completed downloading
'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PowerShellGet'&$skip=40&$top=40'.
DEBUG: 00:00:00.7403986 '27' packages received in the last request.
DEBUG: 00:00:00.7678082 Completed downloading
'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PowerShellGet'&$skip=160&$top=40'.
DEBUG: 00:00:00.7691139 '0' packages received in the last request.
DEBUG: 00:00:00.8493214 Completed downloading
'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PowerShellGet'&$skip=120&$top=40'.
DEBUG: 00:00:00.8507191 '0' packages received in the last request.
DEBUG: 00:00:00.9136121 Completed downloading
'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PowerShellGet'&$skip=80&$top=40'.
DEBUG: 00:00:00.9149540 '0' packages received in the last request.
VERBOSE: Total package yield:'1' for the specified package 'PowerShellGet'.
DEBUG: 00:00:00.9175560 Completed iterating for 'PowerShellGet'.
DEBUG: 00:00:01.0978328 Done calling powershell «Find-Package» «PSModule»
DEBUG: 00:00:01.1209438 Calling New() : MethodName = 'GetInstalledPackages'
DEBUG: 00:00:01.1221484 SkipPublisherCheck: True
DEBUG: 00:00:01.1229892 ProviderName: PowerShellGet
DEBUG: 00:00:01.1238275 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:01.1246763 RequiredVersion: 2.2.5
DEBUG: 00:00:01.1255074 Source: PSGallery
DEBUG: 00:00:01.1263344 AllowClobber: True
DEBUG: 00:00:01.1271587 Force: True
DEBUG: 00:00:01.1279869 Debug: True
DEBUG: 00:00:01.1287135 Scope: AllUsers
DEBUG: 00:00:01.1294122 Verbose: True
DEBUG: 00:00:01.1300991 Type: Module
DEBUG: 00:00:01.1307833 Name: PowerShellGet
DEBUG: 00:00:01.1318035 INVOKING PowerShell Fn Get-InstalledPackage with args PowerShellGet, 2.2.5, , that has length
4
DEBUG: 00:00:01.1415317 In PowerShellGet Provider - 'Get-InstalledPackage'.
DEBUG: 00:00:01.1425397 OPTION: SkipPublisherCheck => True
DEBUG: 00:00:01.1433507 OPTION: ProviderName => PowerShellGet
DEBUG: 00:00:01.1441512 OPTION: MessageResolver => Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:01.1449476 OPTION: RequiredVersion => 2.2.5
DEBUG: 00:00:01.1457317 OPTION: Source => PSGallery
DEBUG: 00:00:01.1465230 OPTION: AllowClobber => True
DEBUG: 00:00:01.1473053 OPTION: Force => True
DEBUG: 00:00:01.1481583 OPTION: Debug => True
DEBUG: 00:00:01.1489707 OPTION: Scope => AllUsers
DEBUG: 00:00:01.1497621 OPTION: Verbose => True
DEBUG: 00:00:01.1505479 OPTION: Type => Module
DEBUG: 00:00:01.1513315 OPTION: Name => PowerShellGet
DEBUG: 00:00:01.2754269 PowerShell Script 'PSModule' Function 'Get-InstalledPackage' returns null.
DEBUG: 00:00:01.2767131 Done calling powershell «Get-InstalledPackage» «PSModule»
It has failed because getting the version with Get-Module PowerShellGet outputs 1.0.0.1 instead of 2.2.5
Let me know if you need any more info
Thanks for looking into this
Thanks Jose Antonio (@santanor) for the outputs! Do you mind confirming that PowerShellGet 2.2.5 has been installed by running Get-Module PowerShellGet - ListAvailable
If you do see it in the list then you can try importing that specific version into your PS Session by running Import-Module PowerShellGet -Version "2.2.5"
Then try Get-Module PowerShellGet - ListAvailable and can double check with (Get-command find-module).Module that both indicate that PowerShellGet v2.2.5 is installed and being utilized.
Also the Get-Module command only shows what is imported in your current PS Session. Using Get-Module PowerShellGet -ListAvailable is a better way to check if a particular module is installed.
Thanks Patrick J. Brown (@pjbrown), sort of a shot in the dark but if you are able to maybe upgrade to PowerShellGet v1.6.7 by using this command, Install-Module 'PowerShellGet' -AllowClobber -RequiredVersion "1.6.7" -Force -Repository 'PSGallery' -SkipPublisherCheck -Debug -Verbose
To confirm its install: Get-InstalledModule PowerShellGet -ListAvailable
and then import the module with Import-Module PowerShellGet -RequiredVersion "1.6.7"
Then do the exact same steps but replace 1.6.7 with 2.2.5.
Activity
StevenBucher98 commentedon Oct 11, 2021
Jose Antonio (@santanor) thanks for outlining your issue here! Would you be able to provide a little more information on the environment you are using? Specifically, the version of PowerShell, you can run
$PSVersionTableand paste the output here just for our reference.StevenBucher98 commentedon Oct 11, 2021
Also do you mind running
Install-Module 'PowerShellGet' -AllowClobber -RequiredVersion "2.2.5" -Force -Repository 'PSGallery' -SkipPublisherCheck -Debug -Verboseand including the output.
Is there a particular reason you need to install PackageManagement 1.4.3? You also do not need to install PackageManagemnt because PowerShellGet installs it. This might be causing your issue because you are installing a lower version of PackageManagement than what is required on PowerShellGet (PackageManagment 1.4.7).
santanor commentedon Oct 12, 2021
Hi Steven Bucher (@StevenBucher98), the environment is defined here
https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/powershell
Running
$PSVersionTableoutputs the following informationI'm not sure, I inherited this script so I'm cautious about making changes. Didn't know I didn't need it.
So I removed the explicit installation of
PackageManagementand tried to run onlyInstall-Module 'PowerShellGet' -AllowClobber -RequiredVersion "2.2.5" -Force -Repository 'PSGallery' -SkipPublisherCheck -Debug -VerboseIt failed with the following output (Sorry, it's quite long)
It has failed because getting the version with
Get-Module PowerShellGetoutputs1.0.0.1instead of2.2.5Let me know if you need any more info
Thanks for looking into this
StevenBucher98 commentedon Oct 12, 2021
Thanks Jose Antonio (@santanor) for the outputs! Do you mind confirming that PowerShellGet 2.2.5 has been installed by running
Get-Module PowerShellGet - ListAvailableIf you do see it in the list then you can try importing that specific version into your PS Session by running
Import-Module PowerShellGet -Version "2.2.5"Then try
Get-Module PowerShellGet - ListAvailableand can double check with(Get-command find-module).Modulethat both indicate that PowerShellGet v2.2.5 is installed and being utilized.StevenBucher98 commentedon Oct 12, 2021
Also the
Get-Modulecommand only shows what is imported in your current PS Session. UsingGet-Module PowerShellGet -ListAvailableis a better way to check if a particular module is installed.PJBowron commentedon Oct 13, 2021
Hi Steven Bucher (@StevenBucher98) - I've been following up on this today while Jose Antonio (@santanor) is busy elsewhere.
I've modified our script to try out some of your suggestions:
This now generates the following output:
I hope this helps. Also note my Powershell-fu is weak; please answer as if to a five-year-old :)
StevenBucher98 commentedon Oct 14, 2021
Thanks Patrick J. Brown (@pjbrown), sort of a shot in the dark but if you are able to maybe upgrade to PowerShellGet v1.6.7 by using this command,
Install-Module 'PowerShellGet' -AllowClobber -RequiredVersion "1.6.7" -Force -Repository 'PSGallery' -SkipPublisherCheck -Debug -VerboseTo confirm its install:
Get-InstalledModule PowerShellGet -ListAvailableand then import the module with
Import-Module PowerShellGet -RequiredVersion "1.6.7"Then do the exact same steps but replace
1.6.7with2.2.5.