PowerShell / PowerShell/PSResourceGet

Sonatype Nexus v2 feeds does not work

Open
#1,466 5 comments 0 reactions 1 assignee View on GitHub

@SydneyhSmith is already working on this.

Since Nov 13, 2023.

Needs-Triage Status-Investigating
Dominant language
C#
Stars
576
Forks
114
Avg merge
1d 2h
Merged PRs (30d)
7

Description

Prerequisites
  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues.
Steps to reproduce

We are trying Sonatype Nexus as a Nuget feed provider and with PowerShellGetV2 we were already able to reach the repository. With PSResourceGet 1.0.0 it is unfortunately no longer possible to use the same repository.

Register the Repository

$RepoName = "Nexus-Powershell"
$RepoUrl = "https://nexus.domain/repository/ps-all-test"
$VaultName = "NexusVault"
$CredentialName = "NexusInstall"

$Splat = @{
	Name = $RepoName
	Uri = $RepoUrl
	Trusted = $true
	CredentialInfo = ([Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo]::new($VaultName, $CredentialName))
}
Register-PSResourceRepository @Splat

Repository type will not be detected by default and set to unknown

Find-PSResource -Repository $RepoName -Name "Test.Module" -Verbose -Debug
Find-PSResource: Repository 'Nexus-Powershell' is not a known repository type that is supported. Please file an issue for support at https://github.com/PowerShell/PSResourceGet/issues

Set ApiVersion to v2

Set-PSResourceRepository -Name $RepoName -ApiVersion v2

Try to find the Module again

Find-PSResource -Repository $RepoName -Name "Test.Module" -Verbose -Debug
Expected behavior
Find/Install the module as like in PowerShellGetV2

PS C:\> Get-Module PowerShellGet

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.2.5                 PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability…}

PS C:\> Get-PSRepository

Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
Nexus-Powershell          Trusted              https://nexus.domain/repository/ps-all-test/
PSGallery                 Trusted              https://www.powershellgallery.com/api/v2

PS C:\> Find-Module Test.Module -Repository Nexus-Powershell -Credential $Cred

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
0.0.1                Test.Module                         Nexus-Powershell     Test.Module Description
Actual behavior
PS> Find-PSResource -Repository $RepoName -Name "Test.Module" -Verbose -Debug
DEBUG: In FindPSResource::ProcessResourceNameParameterSet()
DEBUG: Filtering package name(s) on wildcards
DEBUG: In FindHelper::FindByResourceName()
DEBUG: Parameters passed in >>> Name: 'Test.Module'; ResourceType: 'None'; VersionRange: ''; NuGetVersion: ''; VersionType: 'NoVersion'; Version: ''; Prerelease: 'False'; Tag: ''; Repository: 'Nexus-Powershell'; IncludeDependencies 'False'
VERBOSE: credential successfully read from vault and set for repository: Nexus-Powershell
DEBUG: Searching through repository 'Nexus-Powershell'
DEBUG: In FindHelper::SearchByNames()
DEBUG: No version specified, package name is specified
DEBUG: In V2ServerAPICalls::FindName()
DEBUG: In V2ServerAPICalls::HttpRequestCall()
DEBUG: Request url is 'https://nexus.domain/repository/ps-all-test/FindPackagesById()?id='Test.Module'&$inlinecount=allpages&$filter=IsLatestVersion and Id eq 'Test.Module''
Find-PSResource: TryConvertFromXml: Cannot parse PSResourceInfo from XmlNode with error: Object reference not set to an instance of an object.
Error details
PS> get-error

Exception             :
    Type    : Microsoft.PowerShell.PSResourceGet.UtilClasses.XmlParsingException
    Message : TryConvertFromXml: Cannot parse PSResourceInfo from XmlNode with error: Object reference not set to an instance of an object.
    HResult : -2146233088
TargetObject          : Microsoft.PowerShell.PSResourceGet.Cmdlets.FindHelper
CategoryInfo          : ObjectNotFound: (Microsoft.PowerShel….Cmdlets.FindHelper:FindHelper) [Find-PSResource], XmlParsingException
FullyQualifiedErrorId : FindNameConvertToPSResourceFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource
InvocationInfo        :
    MyCommand        : Find-PSResource
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 150
    Line             : Find-PSResource -Repository $RepoName -Name "Test.Module" -Verbose -Debug
    PositionMessage  : At line:1 char:1
                       + Find-PSResource -Repository $RepoName -Name "Test.Module" -Verbose …
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Find-PSResource
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :
Environment data
Get-Module Microsoft.PowerShell.PSResourceGet

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

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.9
PSEdition                      Core
GitCommitId                    7.3.9
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
Visuals

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.