简体   繁体   中英

Unable to Push GitHub Package for Nuget

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM