首页 > 解决方案 > 尝试将 NuGet 包发布到 gitlab.com 时出现错误“无法加载源的服务索引”

问题描述

我在gitlab.com上有一个私人 C# 项目,想在那里创建一个 NuGet 包。

我按照说明在解决方案级别创建了以下Nuget.config文件。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <packageSources>
 <clear />
 <add key="gitlab" value="https://gitlab.com/api/v4/project/{my_project_numeric_id_here}/packages/nuget/index.json" />
 </packageSources>
 <packageSourceCredentials>
 <gitlab>
     <add key="Username" value="{my_username_in_gitlab}" />
     <add key="ClearTextPassword" value="{my_personal_token_with_api_access_here}" />
 </gitlab>
 </packageSourceCredentials>
</configuration> 

然后我使用 Visual Studio 包管理器控制台并运行以下命令:

dotnet nuget push "C:\{path_to_the_package_here}\MyProject.1.0.0.nupkg" --source gitlab

并出现以下错误:

error: Unable to load the service index for source https://gitlab.com/api/v4/project/{my_project_numeric_id_here}/packages/nuget/index.json.
error: Response status code does not indicate success: 404 (Not Found).

MyProject.1.0.0.nupkg——存在。

Nuget.config— 由命令看到(反映文件中的更改)。

Personal Token— 我用不同的权限玩,至少授予 api 权限,其他所有权限也是如此。

我的操作有什么问题以及如何从 GitLab.com 上的 C# 项目创建 NuGet 包?

标签: gitlabnuget

解决方案


推荐阅读