Can't push content / asset-only NuGet package

I have a GitHub action that creates a content only NuGet package - i.e. there is no csharp projects or .nuspec file it’s just YAML and other config and metadata files about a release. This is created using octo pack:

When attempting to push this to the GitHub Packages NuGet feed I receive the error:

warn : 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.

I tried adding a NuSpec file with these set but I’m not sure that Octopus pack uses that when there’s no project file.

Is there a way to get around this so content / asset / non-binary type nuget packages can be pushed to the feed and consumed?

The RepositoryUrl property corresponds to the following element in a .nuspec file:

<repository type="git" url="https://github.com/OWNER/REPO"  />

There appears to be a bug when packing NuGet files, where the repository element will be omitted completely if the type="git" attribute is missing. I wonder if this might be the problem you’re seeing?

Regards,
Jamie.

Thanks @jcansdale.

There was no <repository> element at all in the NuSpec file and I’m not sure why the GitHub package feed seems to be requiring it when other NuGet feeds did not.

It’s far from ideal but for now I’ve worked around this problem by unzipping the package from octo pack , replacing the .nuspec file with my own that has <repository> set as GitHub expects, and re-zipping to the .nupkg before pushing to GitHub NuGet package feed.

You can also use my gpr tool (from https://github.com/jcansdale) to do this.

dotnet tool install gpr -g
gpr push path/to/*.nupkg -k <PAT> --repository <OWNER/REPO>

This will automatically update the <repository> element before pushing.

I hope that helps!

1 Like