Closed cdhunt closed 1 year ago
Issue-Label Bot is automatically applying the label feature_request
to this issue, with a confidence of 0.89. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!
Links: app homepage, dashboard and code for this bot.
I think Beta6 that was just released added publishing, and Github Packages is Nuget V3 so it may work, have you tried with beta6 yet?
I tried but ended up creating #172.
I got past authentication by doing the following:
nuget.exe sources add -Name GitHub -Source https://nuget.pkg.github.com/ORGNAMEORUSERNAME/index.json -Username ORGNAMEORUSERNAME -Password <PAT>
Register-PSRepository -Name https://nuget.pkg.github.com/ORGNAMEORUSERNAME/index.json -SourceLocation $source -PublishLocation https://nuget.pkg.github.com/ORGNAMEORUSERNAME/index.json
Publish-Module -Path .\ModuleName -Repository GitHub -NuGetApiKey "n/a"
This gives the error Failed to publish module 'ModuleName': 'nuget.exe failed to push Response status code does not indicate success: 400 (Bad Request). '
.
If you trace with Fiddler one of the headers give a clue:
X-Nuget-Warning: No destination repository detected. Ensure the source project has a 'RepositoryUrl' property defined. If you're using a nuspec file, ensure that it has a repository element with the required 'type' and 'url' attributes.
GitHub Packages requires the RepositoryUrl element in the nuspec.
<repository type="git" url="https://github.com/org/project" commit="50af1b9788e251964deb511745dd4716beee4e2b" />
I have the same need to be able to publish pwsh modules into GHPackages.
And I can confirm @jachin84 findings, GHPackages feed requires <repository>
-configuration inside .nuspec
. Unfortunately right now it is not supported by PublishPSResource.createNuspec
and by psd1
-format.
Now I'll try to create pull request to fix this, after figuring out how to use this repo for development.
Oh...
As a result, we are currently not accepting PRs to this repository.
Ok, I think I'll stick with own fork of PowerShellGet2. But nonetheless, let's treat this as feature request? That is, ability to specify module repository metadata. 🤗
I was able to get Publish and Install working today. Publish was a three-step process.
Register-PSResourceRepository -Name nuget-local -URL C:\Nuget\publish\
Publish-PSResource -Path .\mymodule\ -Repository nuget-local
gpr push -k <PAT> C:\Nuget\publish\mymodule.0.1.0.nupkg -r https://github.com/ORG/Repo
gpr is a helper tool for pushing Nuget packages to GitHub Packages that makes it easy to provide the RepositoryURL metadata that GitHub Packages requires. You could also edit the nuspec inside the package after doing the local publish.
To install use PowerShellGet 3.0.0-beta10:
Register-PSResourceRepository -Name github -URL https://nuget.pkg.github.com/ORG/index.json
Install-PSResource -Name mymodule -Repository github -Credential (Get-Credential)
Another hiccup. If your private package depends on a public package, PowerShellGet doesn't know how to find it since GitHub Packages doesn't support feed proxies like Proget and Artifactory. It looks for all of the dependent packages in GitHub and errors out if they can't be found.
Thanks @cdhunt can you please clarify the relationship you expect from GitHub packages and Proget/Artifactory...is the package in GitHub and depends on resources in Proget/Artifactory?
@SydneyhSmith I wasn't expecting a relationship, just stating that GitHub Packages doesn't have the same repository proxy functionality as Proget and Artifactory where you can combine multiple feeds into one API endpoint. The result of that is if you define a module dependency in a private module hosted on GitHub Packages, Install-PSResource assumes the dependent package is also hosted on the same Repository and can't find it unless you publish a copy into your private repository.
In other words, I don't know of a mechanism to define module dependencies that come from different repositories with the current way they are defined in the module manifest. This is really a separate, but related issue I've been meaning to open an issue for.
@cdhunt it would be great if GitHub could address this issue. I do have some ideas of how we can address this client side, but because this isn't a prioritized scenario it likely wouldn't get addressed until Fall. That said if it's an issue that's a major pain point for a lot of folks we can reconsider.
I had mentioned that the dependency handling is kind of bespoke to powershell now and that it should leverage the already-established libraries for dependencies resolution in the nuget client unless theres a really strong reason not to.
@alerickson I'm.... okay... with the way GitHub Packages works. It does what we need, but without PowerShellGet client support, we have to do hacky things like copy public modules into a private feed or do dynamic install on Import-Module.
To the original issue, we have the same publish issues with GitHub Packages for other Nuget packages as well. RepositoryUrl
is not part of the Nuget spec, but I don't see how to get around that. It's a requirement of how Packages is designed because feeds are global to an Org. So, unfortunately, I think all Nuget clients are going to have to adapt.
I think there are plenty of people who would be willing to work on that fix whenever you start accepting PRs, but it'll likely be a GitHub shim.
Is there a v3 feed support roadmap in one of the existing milestones for GA or do we still need to jump through the above hoops outlined by @cdhunt for the time being @SydneyhSmith ?
I'm looking to implement some new internal tooling baselines but I'm hoping for native support before I start the work
This is resolved in PR #1167
I haven't found a way to use PowerShellGet 2.x to publish to GitHub Packages. Please include Packages as a supported repository provider.
All permutations of passing credentials (PAT) return a 401 (Unauthorized).