gpt4 book ai didi

.net - 如何使用 Visual Studio 2019 设置私有(private) Nuget 包注册表?

转载 作者:行者123 更新时间:2023-12-04 00:53:15 25 4
gpt4 key购买 nike

我正在尝试通过 NuGet 包管理器在 Visual Studio 2019 中提供一个 .NET Framework v4.5.2 包,该包来自 Github 的私有(private) NuGet 包注册表系统。
我正在使用的重要东西:

  • .NET 框架 4.5.2
  • Github 操作
  • Github
  • Github 包注册表 (GPR)
  • Visual Studio 2019/NuGet 包管理器

  • 我的目标是什么?
    整个生命周期看起来有点像这样:
  • 我项目的 repo 有一个 CI 工作(Github 品牌)到 msbuild并发布 nupkg .它将所有内容打包并将其部署到 https://nuget.pkg.github.com/ <我的私有(private)组织>。
  • 在 Visual Studio 2019 中,打开给定项目后,用户应该能够引用 https://nuget.pkg.github.com/ 作为自定义 NuGet 提要,并将“我的项目”声明为依赖项。

  • 什么有效,什么无效?
  • GitHub 成功发布我的包裹——我可以在访问 https://github.com/my-private-organization?tab=packages 时看到它.
  • 但是,我 不能使 Visual Studio 2019 支持我的私有(private) NuGet 注册表。当我尝试访问它时,我收到错误:
  • [Private] Failed to retrieve metadata from source 'https://nuget.pkg.github.com/<my-private-organization>/query?q=&skip=0&take=26&prerelease=true&supportedFramework=.NETFramework,Version=v4.7&semVerLevel=2.0.0'.
    Response status code does not indicate success: 401 (Unauthorized).
    当我尝试在浏览器中运行相同的查询 ( GET https://nuget.pkg.github.com/<my-private-organization>/query?q=&skip=0&take=26&prerelease=true&supportedFramework=.NETFramework,Version=v4.7&semVerLevel=2.0.0') 时,系统会提示我输入我的 GitHub 凭据,但输入它们后,我遇到了相同的 401,但出现了不同的错误消息:
    {
    "errors": [
    {
    "code" : "Your token has not been granted the required scopes to execute this query. The 'id' field requires one of the following scopes",
    "message":" ['read:packages'], but your token has only been granted the: [''] scopes. Please modify your token's scopes at: https://github.com/settings/tokens."
    }
    ]
    }
    我肯定有 GITHUB_TOKENread:package perms——在我的 CI 工作中,我首先使用它来生成包。
    我很怀疑...
    我需要通过我的 read:package认证 GITHUB_TOKEN作为额外的身份验证凭据,但我不知道是否/如何在 nuget.config 中配置它.这导致我们...
    我的配置是什么?
    我读到我需要参数化我的 %APPDATA%/NuGet/nuget.config带有一些额外的凭据信息,我从这里获得: https://docs.microsoft.com/en-us/nuget/reference/nuget-config-file#packagesourcecredentials .我可以确认我正在更新正确的 nuget.config文件——我已经能够在 Visual Studio 中使用我正在触摸的文件更改包流名称。现在看起来有点像:
    <!-- file: nuget.config -->
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="Private" value="https://nuget.pkg.github.com/###############/index.json" />
    <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
    </packageSources>
    <packageSourceCredentials>
    <Private>
    <add key="Username" value="###############" />
    <add key="ClearTextPassword" value="*******************" />
    <!-- Could I perhaps need to introduce my Github Access Token here? -->
    </Private>
    </packageSourceCredentials>
    </configuration>
    packageSourceCredentials 中指定的用户名和密码与我在手册中使用的相同 GET在浏览器中完成的查询(在 401 中失败)。
    欢迎所有想法,即使是“没有人做A”。

    最佳答案

    关于.net - 如何使用 Visual Studio 2019 设置私有(private) Nuget 包注册表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64782181/

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