[英]VSTS unable to load the service index for source 401
I'm aware of the other posts about the same signature.我知道关于相同签名的其他帖子。 I still can't resolve my issue after going thru them.经过他们之后,我仍然无法解决我的问题。
My team uses VSTS's build definition for continuous integration.我的团队使用 VSTS 的构建定义进行持续集成。
This build definition works fine until the lastes pull request.这个构建定义工作正常,直到 lastes pull request。 I'm running into the error msg below during the Nuget Restore我在 Nuget 恢复期间遇到了下面的错误消息
2018-06-20T00:37:27.6438127Z System.AggregateException: One or more errors occurred. 2018-06-20T00:37:27.6438127Z System.AggregateException:发生一个或多个错误。 ---> NuGet.Protocol.Core.Types.FatalProtocolException: Unable to load the service index for source https://microsoft.pkgs.visualstudio.com/_packaging/CBT/nuget/v3/index.json . ---> NuGet.Protocol.Core.Types.FatalProtocolException:无法加载源https://microsoft.pkgs.visualstudio.com/_packaging/CBT/nuget/v3/index.json的服务索引。 ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized). ---> System.Net.Http.HttpRequestException: 响应状态代码未指示成功:401(未经授权)。
I do have https://microsoft.pkgs.visualstudio.com/_packaging/CBT/nuget/v3/index.json in the nuget.config, and there is nothing changed in the nuget.config in the failing PR我在 nuget.config 中有https://microsoft.pkgs.visualstudio.com/_packaging/CBT/nuget/v3/index.json ,并且在失败的 PR 中的 nuget.config 中没有任何变化
I can nuget restore and build the entire solution successfully on my local machine using VS2017.我可以使用 VS2017 在我的本地机器上成功地恢复和构建整个解决方案。 The only related change in the PR is that instead of using package.config, it uses packagereference to get the nuget package. PR 中唯一相关的更改是它使用 packagereference 来获取 nuget 包,而不是使用 package.config。 I tried to move back to using package.config, the build would still fail with the same error msg.我试图回到使用 package.config,构建仍然会失败并显示相同的错误消息。
Thanks in advance.提前致谢。
You can update the VSTS feed with credentail (PAT or alternate credential) in the specified nuget.config
file.可以使用指定nuget.config
文件中的凭据(PAT 或备用凭据)更新 VSTS nuget.config
。
Such as:如:
nuget sources update -Name "vstsfeed" -Source https://microsoft.pkgs.visualstudio.com/_packaging/CBT/nuget/v3/index.json -Username "Alternate username" -Password "alternate password" -configfile /path/to/nuget.config
Then you can commit the changes for the nuget.config
file and push to VSTS repo.然后,您可以提交对nuget.config
文件的更改并推送到 VSTS 存储库。 And build again to check if it works.并再次构建以检查它是否有效。
You can use a command as shown in the accepted answer - also, you can add the feed in a nuget.config file placed in the root of your repo您可以使用已接受的答案中所示的命令 - 此外,您还可以在位于存储库根目录的 nuget.config 文件中添加提要
Notice, this shows how to add credentials for a custom feed with spaces in the feed name:
My Nuget Artifacts
请注意,这显示了如何为提要名称中带有空格的自定义提要添加凭据:My Nuget Artifacts
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<!-- Allow NuGet to download missing packages -->
<add key="enabled" value="True" />
<!-- Automatically check for missing packages during build in Visual Studio -->
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
<add key="My Nuget Artifacts" value="https://pkgs.dev.azure.com/ConsotoOrg/_packaging/Consoto/nuget/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<My_x0020_NuGet_x0020_Artifacts>
<add key="Username" value="justme" />
<add key="ClearTextPassword" value="xyzyoqyvslyfs1t1khru6wd33gebujhpr9moocbujfhv8ukxtxyz" />
</My_x0020_NuGet_x0020_Artifacts>
</packageSourceCredentials>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
<!--
Used to specify trusted signers to allow during signature verification.
See: nuget.exe help trusted-signers
-->
<trustedSigners>
<author name="microsoft">
<certificate fingerprint="3F9001EA83C560D712C24CF213C3D312CB3BFF51EE89435D3430BD06B5D0EECE" hashAlgorithm="SHA256" allowUntrustedRoot="false" />
</author>
<repository name="nuget.org" serviceIndex="https://api.nuget.org/v3/index.json">
<certificate fingerprint="0E5F38F57DC1BCC806D8494F4F90FBCEDD988B46760709CBEEC6F4219AA6157D" hashAlgorithm="SHA256" allowUntrustedRoot="false" />
<owners>microsoft;aspnet;nuget</owners>
</repository>
</trustedSigners>
</configuration>
FWIW - In recent days, I've found I can clear up some NuGet restore errors by removing the
trustedSigners
section from the config FWIW - 最近几天,我发现我可以通过从配置中删除trustedSigners
部分来清除一些 NuGet 还原错误
This is not what the problem was with the OP but I'm adding a note here since I found this question while searching for the same error message.这不是 OP 的问题所在,但我在这里添加了一条注释,因为我在搜索相同的错误消息时发现了这个问题。
In our case we were building a .net 5 app for in Azure DevOps.在我们的例子中,我们正在为 Azure DevOps 构建一个 .net 5 应用程序。 We had to upgrade to a newer version of NuGet using the NuGet tool installer.我们必须使用 NuGet 工具安装程序升级到较新版本的 NuGet。 Then the restore worked just fine using the .Net Core task with the restore command.然后使用带有 restore 命令的 .Net Core 任务恢复工作得很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.