1

I followed all guidance so as to be able to push a nuget package of my class library into my private GitHub repository.

I added the following to my csproj

<PropertyGroup>
       <TargetFramework>net5.0</TargetFramework>
       <PackageId>NextWareProductPortalClientServices</PackageId>
       <Version>1.0.1</Version>
       <Authors>CodeGenerator</Authors>
       <Company>NextWare</Company>
       <PackageDescription>This package adds gRPC client library for the NextWare ProductPortal 
       </PackageDescription>
       <RepositoryUrl>https://github.com/NextWareGroup/PPD</RepositoryUrl>
 </PropertyGroup>

I added the following nuget.config file to the root of the project..

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageSources>
        <clear />
        <add key="github" value="https://nuget.pkg.github.com/jkears/index.json" />
    </packageSources>
    <packageSourceCredentials>
        <github>
            <add key="Username" value="jkears" />
            <add key="ClearTextPassword" value="******6d5a57b7527dfcc646b62ca7d1*****" />
        </github>
    </packageSourceCredentials>
</configuration>

The Personal Token has all permissions applied.

After running the dotnet cli to create the package I see the package in the bin\release folder. Then I attempt to run the following command...

dotnet nuget push "bin/Release/NextWareProductPortalClientServices.1.0.1.nupkg" --source "github"

The output is as follows;

warn : No API Key was provided and no API Key could be found for 'https://nuget.pkg.github.com/jkears'. To save an API Key for a source use the 'setApiKey' command.
Pushing NextWareProductPortalClientServices.1.0.1.nupkg to 'https://nuget.pkg.github.com/jkears'...
  PUT https://nuget.pkg.github.com/jkears/
An error was encountered when fetching 'PUT https://nuget.pkg.github.com/jkears/'. The request will now be retried.
An error occurred while sending the request.
  The response ended prematurely.
  PUT https://nuget.pkg.github.com/jkears/
An error was encountered when fetching 'PUT https://nuget.pkg.github.com/jkears/'. The request will now be retried.
An error occurred while sending the request.
  The response ended prematurely.
  PUT https://nuget.pkg.github.com/jkears/
error: An error occurred while sending the request.
error:   The response ended prematurely.

I have researched this issue but none of the reported fixes work for me, including running directly from Nuget CLI.

riQQ
  • 9,878
  • 7
  • 49
  • 66
John Kears
  • 677
  • 6
  • 20
  • I've the same problem. Can you try this `dotnet nuget push "bin/Release/NextWareProductPortalClientServices.1.0.1.nupkg" --source "github" --api-key YOUR_API_KEY`. This solves my API_KEY problem but now I'm getting No destination repository detected error. – Kenan Nur Dec 07 '20 at 13:02
  • I think above command solves your problem but after that you can get the same error as me. – Kenan Nur Dec 07 '20 at 13:05
  • Thanks @KenanNur. Later today I will try youe solution, perhaps collectively we will get this to work. In my case the curl based solution will work for my needs. I code generate microservices following DDD principals and my need to push as nuget packages it to support integration with previously generated class libraries from other domain models. I just need a CLI type approach that I can run in the GitHub Action flows, and the curl solution should be enough to support that need. – John Kears Dec 08 '20 at 14:07

1 Answers1

2

While not the answer I was able to push the nuget package using the following curl command..

curl -vX PUT -u "[OwnerName]:[PersonalToken]" -F package=@NextWareProductPortalClientServices.1.0.1.nupkg https://nuget.pkg.github.com/jkears/

I am not sure why the DotNet CLI does not work, but the above does which is all I need.

Dharman
  • 30,962
  • 25
  • 85
  • 135
John Kears
  • 677
  • 6
  • 20