Dav*_*tti 5 c# nuget .net-core
dotnet restore 在某些包裹上出乎意料地失败了,我无法弄清楚原因.
我有一个通过VSTS Packages扩展托管的私有nuget repo,我的NuGet.Config看起来像(如此处所述https://www.visualstudio.com/en-us/docs/package/nuget/auth#dotnet-core)
<?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="MyPackages" value="https://{myaccount}.pkgs.visualstudio.com/_packaging/{myfeed}/nuget/v3/index.json"` />
</packageSources>
<packageCredentials>
<MyPackages>
<add key="Username" value="vsts" />
<add key="ClearTextPassword" value="{my PAT}" />
</MyPackages>
</packageCredentials>
</configuration>
Run Code Online (Sandbox Code Playgroud)
如果我使用dotnet new console并添加对我的Feed上托管的包的引用来创建新项目,则还原工作正常.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="My.Lib" Version="1.0.0"></PackageReference>
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
但是,如果我还包含对NEST版本2.5.0(或任何版本)的软件包引用,则dotnet --info[C:\ Users\test\dotnet\dotnet.csproj] C:\ Program Files\dotnet\sdk \会失败
. 1.0.0\NuGet.targets(97,5):错误:响应状态代码不表示成功:401(未授权).[C:\ Users \用户测试\ DOTNET\dotnet.csproj]`
但奇怪的是,用其他任何恢复替换NEST都会有效.例如,添加ElasticSearch.Net 2.5.0将正常工作.
如果我从我的nuget.config中删除我的包凭据和私有nuget feed并且仅引用NEST,那么它可以工作 - 但是我无法访问我的私人订阅源.
最后最奇怪的是昨天恢复工作正常,但现在对我和我的同事来说,我们无法恢复.
这是VSTS包问题吗?NEST可能有什么不同?
dotnet恢复不应该无法恢复
dotnet恢复失败 - 引用来自私有nuget feed的401未经授权的响应
error : Unable to resolve NestOops
dotnet restore 输出:
C:\Program Files\dotnet\sdk\1.0.0\NuGet.targets(97,5): error : Unable to load the service index for source https://{myaccount}.pkgs.visualstudio.com/_packaging/{myfeed}/nuget/v3/index.json.\r `[C:\Users\test\dotnet\dotnet.csproj]
C:\Program Files\dotnet\sdk\1.0.0\NuGet.targets(97,5): error : Response status code does not indicate success: 401 (Unauthorized). [C:\Users\test\dotnet\dotnet.csproj]
Run Code Online (Sandbox Code Playgroud)
完整的控制台输出
dotnet new console
更多信息 -
似乎当我只使用官方的nuget.org源代码时,NEST将像预期的那样工作,就像任何其他nuget包一样.如果包名中有拼写错误,则会出现错误dotnet --info
但是当我将我的nuget源作为附加包源时,包名称的任何拼写错误都会导致我的Feed中出现401.我仍然不知道为什么NEST有同样的错误.
看起来像是虚惊一场!
NuGet 配置不太正确 -<packageCredentials>应该是<packageSourceCredentials>.
我的猜测是,VSTS feed 中的一些包被缓存了(一个单独的项目有自己的配置,具有正确的元素,首先将它们放入缓存中),这就是为什么它们似乎可以正确解析,即使它们不是' t 验证正确。然后,每当查找不在缓存中的包时,它就会使用错误的凭据访问我们的提要并失败。