question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When using a PSRepository backed by Azure Devops Artifact feed that upstreams PSGallery, Install-Module fails on specific module versions

See original GitHub issue

Steps to reproduce

  1. Create an Azure Devops Artifact feed (org or team project scoped) called privatepsgallery and upstream powershellgallery.
  2. Generate a personal access token with Package read/write permission within the organization containing the Artifact feed
  3. Execute the following in PSCore, remembering to replace yourazdopat and yourazdoorganization placeholders with relevant values.
$VSCred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList @('youremail@yourdomain.com', (ConvertTo-SecureString -String 'yourazdopat' -AsPlainText -Force))
Register-PSRepository -Name 'PrivatePSGallery' -SourceLocation 'https://pkgs.dev.azure.com/yourazdoorganization/_packaging/privatepsgallery/nuget/v2' -Credential $VSCred -InstallationPolicy Trusted
Find-Module -Name 'AzurePipelinesPS' -AllVersions -Repository psgallery -ErrorAction SilentlyContinue | Where-Object { $_.Version -inotlike '*-*' -and ([System.Version] $_.Version -ge [System.Version] '1.0.0' ) } | Select-Object -Property Name, Version, @{ label = 'SortableVersion'; expression = { [System.Version] $_.Version }} | Sort-Object -Property SortableVersion | Foreach-object {
         Write-Host "Installing module $($_.Name) and version $($_.Version)"
         Install-Module -Name $_.Name -RequiredVersion $_.Version -Repository privatepsgallery -Credential $vscred -Scope allusers -AllowClobber -SkipPublisherCheck
}

To reproduce the issue encountered with AWS.Tools.* modules, use this script below.

 [string[]] $Modules = @('AWS.Tools.ElasticLoadBalancingV2', 'AWS.Tools.Pricing', 'AWS.Tools.RDS', 'AWS.Tools.Route53', 'AWS.Tools.S3', 'AWS.Tools.SecurityToken', 'AWS.Tools.SimpleSystemsManagement')
 foreach ($Module in $Modules)
 {
    Find-Module -Name $Module -AllVersions -Repository psgallery -ErrorAction SilentlyContinue | Where-Object { $_.Version -inotlike '*-*' -and ( [System.Version] $_.Version -ge [System.Version] '4.0.0')} | Select-Object -Property Name, Version, @{ label = 'SortableVersion'; expression = { [System.Version] $_.Version }} | Sort-Object -Property SortableVersion | Foreach-object {
        Install-Module -Name $_.Name -RequiredVersion $_.Version -Repository privatepsgallery -Credential $vscred -Scope allusers -AllowClobber -SkipPublisherCheck
    }
 }

Expected behavior

When the module or requiredversion is not found in azure devops feed, it should fetch the module from powershellgallery and make it visible in Azure Devops.

Actual behavior

I get an error like this:

Install-Package: No match was found for the specified search criteria and module name 'AzurePipelinesPS'. Try Get-PSRepository to see all available registered module repositories.

Looking at Azure Devops, I can tell where it’s failed, starting with version 3.1.42 of AzurePipelinesPS. I experience the same issues with SqlServerDSC on any version newer than 15.0.1 (e.g., 15.1.0, 15.1.1, 15.2.0). AWS.Tools.Common, AWS.Tools.EKS, AWS.Tools.EC2, etc all fail as well between versions 4.1.99 and 4.1.86, inclusive and 4.1.9.0. Due to the consistency of versions affected in AWS.Tools.* modules, I’m leaning towards corruption of version metadata stored in PSGallery’s index/database when AWS pushed these versions to PSGallery.

image

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      7.2.4
PSEdition                      Core
GitCommitId                    7.2.4
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
> Get-Module -ListAvailable PowerShellGet,PackageManagement
ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     2.2.5                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-M…

    Directory: C:\program files\powershell\7\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.4.7                 PackageManagement                   Desk      {Find-Package, Get-Package, Get-Package…
Script     2.2.5                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-M…

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Binary     1.0.0.1               PackageManagement                   Desk      {Find-Package, Get-Package, Get-Package…
Script     1.0.0.1               PowerShellGet                       Desk      {Install-Module, Find-Module, Save-Modu…
> Get-PackageProvider -ListAvailable
Name                     Version          DynamicOptions
----                     -------          --------------
NuGet                    3.0.0.1          Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, …
PowerShellGet            2.2.5.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, In…
PowerShellGet            1.0.0.1

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
anamnavicommented, Jun 30, 2022

@tristanbarcelon I’ll test and get back on this early next week, sorry for the delay, just coming back from vacation.

1reaction
anamnavicommented, Jun 23, 2022

@tristanbarcelon thanks for reaching out with this! We’re looking into this scenario and seeing what’s happening and will get back soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use Azure Artifacts feeds as a private PowerShell repository
This article will guide you through setting up your Azure Artifacts feed as a private PowerShell repository to store and share your PowerShell ......
Read more >
Azure: PowerShell module properly pushed to artifacts ...
My purpose is to configure a private feed for being able to use my PowerShell modules inside Azure Pipelines. I've followed step by...
Read more >
3.0-Consider Milestone
When using a PSRepository backed by Azure Devops Artifact feed that upstreams PSGallery, Install-Module fails on specific module versions Needs-Attention.
Read more >
Creating a Private PSRepository in Azure | How - PowerShell
I set out to create an internal PSRepository for my scripts and modules, like a PowerShell Gallery but with authentication and only for...
Read more >
Allow PowerShell Gallery to be added as a public ...
However when trying to do so it only allows the pre-defined public sources or to add a custom NPM feed but no custom...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found