gpt4 book ai didi

nuget - 恢复包时 dotnet build 命令失败

转载 作者:行者123 更新时间:2023-12-05 02:15:46 26 4
gpt4 key购买 nike

我有一个在本地构建良好的项目,但在 VSTS 中构建它在 dotnet build 命令中失败。这个错误对我来说看起来很奇怪,因为我不知道为什么构建命令会再次尝试恢复包。错误如下所示:

2018-07-09T11:06:48.2541705Z Retrying 'FindPackagesByIdAsync' for source 'https://mycompany.pkgs.visualstudio.com/_packaging/5b9fd539-d653-4771-aa3c-6544d73b1234/nuget/v3/flat2/system.data.sqlclient/index.json'. 2018-07-09T11:06:48.2562315Z Response status code does not indicate success: 401 (Unauthorized).

在构建步骤之前,我有一个成功完成的 dotnet 还原步骤。还原步骤使用 NuGet.config 文件,其中包含 VSTS 中的私有(private)提要,但 URL 看起来与错误中的不相似。这里的文件只是为了清楚起见。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="MyCompany.NuGet.Internal" value="https://MyCompany.pkgs.visualstudio.com/_packaging/MyCompany.NuGet.Internal/nuget/v3/index.json" />
<add key="MyCompany.NuGet.ThirdParty" value="https://MyCompany.pkgs.visualstudio.com/_packaging/MyCompany.Nuget.ThirdParty/nuget/v3/index.json" />
</packageSources>
</configuration>

这可能是什么问题? dotnet 构建步骤是否完全忽略 NuGet.config 文件并尝试项目中的提要?我不知道该供稿 URL 是如何生成的。

最佳答案

我能够通过将 --no-restore 参数传递给 dotnet build 命令来解决问题。

我刚刚读了this article here并想试一试,结果成功了。

With .NET Core 1.x SDK, you needed to explicitly run the dotnet restore before running dotnet build. Starting with .NET Core 2.0 SDK, dotnet restore runs implicitly when you run dotnet build. If you want to disable implicit restore when running the build command, you can pass the --no-restore option

看起来 VSTS 中的 dotnet build 不关心 NuGet.config 文件,并尝试在没有它的情况下进行恢复。

关于nuget - 恢复包时 dotnet build 命令失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51244716/

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