【发布时间】:2020-12-04 17:45:59
【问题描述】:
我遵循了所有指导,以便能够将我的类库的 nuget 包推送到我的私有 GitHub 存储库中。
我在我的 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>
我将以下 nuget.config 文件添加到项目的根目录..
<?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>
个人令牌已应用所有权限。
运行 dotnet cli 创建包后,我在 bin\release 文件夹中看到了包。 然后我尝试运行以下命令...
dotnet nuget push "bin/Release/NextWareProductPortalClientServices.1.0.1.nupkg" --source "github"
输出如下;
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.
我已经研究过这个问题,但报告的修复都不适用于我,包括直接从 Nuget CLI 运行。
【问题讨论】:
-
我也有同样的问题。你能试试这个
dotnet nuget push "bin/Release/NextWareProductPortalClientServices.1.0.1.nupkg" --source "github" --api-key YOUR_API_KEY。这解决了我的 API_KEY 问题,但现在我收到 No destination repository detected 错误。 -
我认为上面的命令可以解决你的问题,但之后你会得到和我一样的错误。
-
谢谢@KenanNur。今天晚些时候我会尝试你的解决方案,也许我们会集体解决这个问题。在我的情况下,基于 curl 的解决方案将满足我的需求。我根据 DDD 原则编写代码生成微服务,并且我需要将其作为 nuget 包推送,以支持与以前从其他域模型生成的类库的集成。我只需要一个可以在 GitHub Action 流中运行的 CLI 类型方法,并且 curl 解决方案应该足以支持该需求。
标签: .net nuget-package github-package-registry