gpt4 book ai didi

.net - 如何将 Nuget 包推送到 GitHub 包?

转载 作者:行者123 更新时间:2023-12-05 06:08:04 26 4
gpt4 key购买 nike

我正在尝试将简单的 .Net Core 类库推送到 GitHub Packages。我已阅读 https://docs.github.com/en/free-pro-team@latest/packages/using-github-packages-with-your-projects-ecosystem/configuring-dotnet-cli-for-use-with-github-packages 中的所有文档

我已经创建了 .nupkg 文件,但无法将其推送到 GitHub。我怎样才能做到这一点?推送命令给出以下错误:

dotnet nuget push "bin/Release/Vegas.Util.AppLogger.1.0.0.nupkg" --source "github"

PUT https://nuget.pkg.github.com/kenannur/
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.
BadRequest https://nuget.pkg.github.com/kenannur/ 155 ms
error: Response status code does not indicate success: 400 (Bad Request).

这是我项目中的 nuget.config

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

这是.csproj文件

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<PackageId>Vegas.Util.AppLogger</PackageId>
<Authors>Kenan Nur</Authors>
<Owners>kenannur</Owners>
<PackageTags>log logger</PackageTags>
<Title>AppLogger</Title>
<Description>Basit console logger</Description>
<PackageVersion>1.0.0</PackageVersion>
<Version>1.0.0</Version>
<RepositoryUrl>https://github.com/kenannur/applogger</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NuGet.Build.Packaging" Version="0.2.5-dev.8">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>

最佳答案

对于那些仍在寻找解决方案的人。

  1. 将以下行添加到您的 csrpoj 文件中的标记之间:
<RepositoryUrl>here goes your repo url</RepositoryUrl>

例如:

<PropertyGroup>
...
<RepositoryUrl>https://github.com/johndoe/hello-world.git</RepositoryUrl>
</PropertyGroup>
  1. dotnet pack --configuration Release

  2. 您现在可以使用所需参数运行 dotnet nuget push

关于.net - 如何将 Nuget 包推送到 GitHub 包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65182182/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com