恢复软件包时,dotnet build命令失败 [英] dotnet build command fails while restoring packages

查看:761
本文介绍了恢复软件包时,dotnet build命令失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在本地可以正常构建的项目,但是在VSTS中的构建在dotnet build命令中失败.该错误对我来说似乎很奇怪,因为我不知道为什么构建命令会尝试再次还原软件包.错误显示如下:

I have a project that's building fine locally but the build in VSTS it fails in dotnet build command. The error looks very strange to me because I have no idea why a build command would try to restore packages again. Here's what the error looks like:

2018-07-09T11:06:48.2541705Z重试'FindPackagesByIdAsync' 来源 '

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中包含私有提要,但URL看起来与错误中的URL不相似.这是为了清楚起见的文件.

Prior to build step, I have a dotnet restore step which is completed successfully. Restore step uses a NuGet.config file which includes private feeds in VSTS but the URLs do not look similar to the one in the error. Here's the file just to make it clear.

<?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是如何生成的.

What could be the problem here? Is dotnet build step ignoring the NuGet.config file completely and trying the feeds in the project? I have no idea how that feed URL is generated.

推荐答案

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

I was able to resolve the issue by passing --no-restore argument to dotnet build command.

我刚刚阅读了这篇文章在这里,并想尝试一下就可以了.

I just read this article here and wanted to give it a shot and it worked.

使用.NET Core 1.x SDK,您需要显式运行dotnet 在运行dotnet build之前还原.从.NET Core 2.0 SDK开始, 当您运行dotnet build时,dotnet还原将隐式运行.如果你想 要在运行build命令时禁用隐式还原,您可以 通过--no-restore选项

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文件,并尝试在没有该文件的情况下进行还原.

It looks like dotnet build in VSTS does not care about the NuGet.config file and tries to do a restore without it.

这篇关于恢复软件包时,dotnet build命令失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆