Skip to content

Use NuGet Package Registry for PowerShell Modules #34486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
marvint24 opened this issue May 16, 2025 · 1 comment
Open

Use NuGet Package Registry for PowerShell Modules #34486

marvint24 opened this issue May 16, 2025 · 1 comment
Labels

Comments

@marvint24
Copy link

Description

Referring to my post in the forum: https://forum.gitea.com/t/nuget-package-registry-for-powershell-modules/11226

My goal is using Gitea as a registry for custom PowerShell modules.

Current behavier

  • Registering gitea as PSRepository works well.
  • Publishing my module works too.
  • Finding the module works not correct.
  • Installing Module doesn't work.

The problem occurs with PowerShell 5.1 on Windows and PowerShell 7 on Windows / Linux

Expected behavier

The NuGet package registry should work as PowerShell module repository.

Steps to reproduce

You can use this code https://github.com/marvint24/PWSHTest to test it.

  1. Clone repo
  2. Create an access token in gitea
  3. Run the publishModule.ps1 file like as described in the readme

After that you should find the package in gitea.

You can find the PowerShell module with:

Find-Module -Name "*" -Repository Gitea -Verbose

But not with:

Find-Module -Name "PWSHTest" -Repository Gitea -Verbose

You cannot install the module with:

Install-Module -Name "PWSHTest" -Repository Gitea -Verbose

Gitea Version

1.23.8

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

https://gist.github.com/marvint24/da65ff545a0b207dcd46003aef411be7

Screenshots

Image

Git Version

2.45.2

Operating System

gitea docker image (Alpine 3.20.3)

How are you running Gitea?

I am using a docker compose file like https://docs.gitea.com/installation/install-with-docker

Database

SQLite

@senna-fox
Copy link

Jumping in to say I've also run into this issue.

Find-Module -Name PWSHTest -Repository Gitea -Verbose
VERBOSE: Suppressed Verbose Repository details, Name = 'Gitea', Location = 'https://gitea.xxx.com/api/packages/audrey/nuget/index.json'; IsTrusted = 'True'; IsRegistered = 'True'.
VERBOSE: Repository details, Name = 'Gitea', Location = 'https://gitea.xxx.com/api/packages/audrey/nuget/index.json'; IsTrusted = 'True'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: Using the specified source names : 'Gitea'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://gitea.xxx.com/api/packages/audrey/nuget/index.json' and PackageManagementProvider is 'NuGet'.
VERBOSE: Retry downloading 'https://gitea.xxx.com/api/packages/audrey/nuget/registration/pwshtest/1.1.json' for '0' more times
VERBOSE: Total package yield:'0' for the specified package 'PWSHTest'.
Find-Package: No match was found for the specified search criteria and module name 'PWSHTest'. Try Get-PSRepository to see all available registered module repositories.
# Error Returned
PackageManagement\Find-Package : No match was found for the specified search criteria and module name 'PWSHTest'. Try
Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:8879 char:9
+         PackageManagement\Find-Package @PSBoundParameters | Microsoft ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...ets.FindPackage:FindPackage) [Find-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage

If the latest version of a package ends with .0, the above error is returned.
If I navigate to https://gitea.xxx.com/api/packages/audrey/nuget/registration/pwshtest/1.1.json I get a Package Not Found page. If I navigate to https://gitea.xxx.com/api/packages/audrey/nuget/registration/pwshtest/1.1.0.json the correct manifest is returned.
The above only occurs if the minor version is a 0. If the minor version ends with any other integer then the below appears.

VERBOSE: Suppressed Verbose Repository details, Name = 'Gitea', Location =
'https://gitea.xxx.com/api/packages/audrey/nuget/index.json'; IsTrusted = 'True'; IsRegistered = 'True'.
VERBOSE: Repository details, Name = 'Gitea', Location = 'https://gitea.xxx.com/api/packages/audrey/nuget/index.json'; IsTrusted =
'True'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: Using the specified source names : 'Gitea'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://gitea.xxx.com/api/packages/audrey/nuget/index.json' and PackageManagementProvider is
'NuGet'.
VERBOSE: Total package yield:'0' for the specified package 'PWSHTest'.
# Error Result
PackageManagement\Find-Package : No match was found for the specified search criteria and module name 'PWSHTest'. Try
Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:8879 char:9
+         PackageManagement\Find-Package @PSBoundParameters | Microsoft ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...ets.FindPackage:FindPackage) [Find-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage

Interestingly, if I run the same Find-Module cmdlet with an asterisk at the start or end, it works.

find-module -name PWSHTest* -Repository Gitea -Verbose
VERBOSE: Suppressed Verbose Repository details, Name = 'Gitea', Location =
'https://gitea.xxx.com/api/packages/audrey/nuget/index.json'; IsTrusted = 'True'; IsRegistered = 'True'.
VERBOSE: Repository details, Name = 'Gitea', Location = 'https://gitea.xxx.com/api/packages/audrey/nuget/index.json'; IsTrusted =
'True'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: Using the specified source names : 'Gitea'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://gitea.xxx.com/api/packages/audrey/nuget/index.json' and PackageManagementProvider is
'NuGet'.
VERBOSE: Total package yield:'0' for the specified package 'PWSHTest*'.
VERBOSE: Searching repository 'https://gitea.xxx.com/api/packages/audrey/nuget/index.json' for 'searchTerm:PWSHTest'.
VERBOSE: Total package yield:'1' for the specified package 'PWSHTest*'.
# Result
Version              Name                                Repository           Description
-------              ----                                ----------           -----------
1.3.0                PWSHTest                          Gitea                Provides helpers for interacting with the MongooseAPI...

Note

Some of these error logs report different version numbers. This was done intentionally for the purpose of log collection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants