I have been able to successfully publish a PowerShell module of my own creation to the repo's GitHub Packages location. I have utilized several resources to get that accomplished.
The problem comes in after that. I cannot seem to be able to run Find-Module
and get anything from the specified registered PSRepository.
If I delete the package so there are no collisions, I can register a PSRepository with the GitHub Package location:
Register-PSRepository -Name GitHub -SourceLocation https://nuget.pkg.github.com/beau-witter/index.json -PublishLocation https://nuget.pkg.github.com/beau-witter/index.json -InstallationPolicy Trusted
and then publish to that Repository without issue:
Publish-Module -Path path/to/module -Repository GitHub -NuGetApiKey "<GITHUB_API_KEY>"
If I run that publish again, I will receive the error:
Write-Error: Failed to publish module 'NetworkAnalyzer': 'nuget.exe failed to push Response status code does not indicate success: 409 (Conflict). '.
Indicating that the first publish was successful and now can't put the same package at the same version in that location.
However, running Find-Module -Repository GitHub -Credential $BuiltCredentialObject
I just receive null back. Everything on the GitHub page for Working with the NuGet registry seems to explicitly assume this is going through a .NET project/or solution with .csproj files and running dotnet
. Besides that, the actual steps for installing seems pretty hand-wavy and unclear. This NuGet Issue on GitHub seems to suggest it can be done:
Can GitHub act as a PSRepository which would make PowerShellGet commands see it as a PSRepository?
In theory, yes. See https://docs.microsoft.com/en-us/powershell/scripting/gallery/how-to/working-with-local-psrepositories?view=powershell-6
But again, that is dealing almost entirely with Publishing, not consuming.
Is it possible to actually consume the valid PowerShell modules from the GitHub Packages NuGet package repository?