PowerShell / PowerShell/PSResourceGet

PSResourceGet installs nuget.org packages like they were PowerShell packages

Open
#1,612 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-Install Issue-Bug Up-For-Grabs
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

As you can add any nuget v2 and v3 repository to PSResourceGet, maybe it would be smart to validate whether packages are ment for PowerShell before installing?

Take NuGet.Versioning for instance, it installs to $env:PSModulePath as a PowerShell module, but can't be imported as a module.

Steps to reproduce:

# Assets
$Repo = [ordered]@{
    'Name' = [string] 'NuGetv3'
    'Uri'  = [string] 'https://api.nuget.org/v3/index.json'
}


# Register NuGet as a resource repository
Register-PSResourceRepository -Name $Repo.'Name' -Priority 60 -ApiVersion 'V3' -Uri $Repo.'Uri'


# Find latest version of NuGet.Versioning from nuget.org
Find-PSResource -Repository $Repo.'Name' -Name 'NuGet.Versioning' | Format-List


# Install it
Install-PSResource -Repository $Repo.'Name' -TrustRepository -Scope 'CurrentUser' -Name 'NuGet.Versioning'


# Find it locally
Get-InstalledPSResource -Name 'NuGet.Versioning' | Format-List


# Try to import it - Does not work
Import-Module -Name 'NuGet.Versioning'


# One can add it as type though
## Find info for latest installed version
$NuGetVersioning = Get-InstalledPSResource -Name 'NuGet.Versioning' |
    Sort-Object -Property 'Version' -Descending |
    Select-Object -First 1

## Add type
Add-Type -Path (
    [System.IO.Path]::Combine(
        $NuGetVersioning.'InstalledLocation',
        'NuGet.Versioning',
        $NuGetVersioning.'Version'.ToString(),
        'lib',
        'netstandard2.0',
        'NuGet.Versioning.dll'
    )
)

## Test it
[NuGet.Versioning.NuGetVersion]'1.2.3'

Related comments:

Expected behavior

Validate whether a package is made for PowerShell. Tags? Content when decompressed?

Alternatively, do something else with non-PowerShell NuGet packages? Add to different path or something.

Actual behavior

Installs non-PowerShell resources as if they were modules.

Error details

No response

Environment data
  • Windows 11 23H2
  • Microsoft.PowerShell.PSResourceGet v1.0.3
  • PowerShell v7.4.1 x64
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.

Research direction

Start by running the provided Register-PSResourceRepository, Find-PSResource, and Install-PSResource reproduction against nuget.org, then trace how PSResourceGet identifies and places downloaded packages. Define and implement a decision for non-PowerShell NuGet packages, and verify that NuGet.Versioning is no longer installed as an importable PowerShell module while valid PowerShell packages retain their existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.