简体   繁体   中英

NU1100 Error When Attempting to Pull NuGet Package From Private NuGet Repo

I have a .NET Core 2.1 that is referencing a NuGet package sitting in a private NuGet repository.

I've added a nuget.config at the solution level that adds the private repository source and referenced it through my dotnet restore .

I'm getting the error:

Error NU1100: Unable to resolve 'xxx (>= xxx)' for '.NETCoreApp,Version2.1'.

From what I can tell the restore is attempting to pull the .NET Core 2.1 version of the package, but the package is built against .NET Standard 2.

Additionally, adding the source through VS2017 doesn't have any issue pulling the package.

How can I tell the restore to look for the standard version of the package?

Edit:

nuget.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <packageSources>
      <add key="Official NuGet Feed" value="http://api.nuget.org/v3/index.json" />
      <add key="Internal NuGet Feed" value="\\{Path}\NugetPkg" />
    </packageSources>
  </config>
</configuration>

Project File

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="______.Client" Version="0.1.8-beta" />
  </ItemGroup>

</Project>

Some Git Bash Output

user@desktop MINGW64 /c/Dev/TestNuget (master)
$ ls
nuget.config  TestNuget  TestNuget.sln

user@desktop MINGW64 /c/Dev/TestNuget (master)
$ dotnet build
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restoring packages for C:\Dev\TestNuget\TestNuget\TestNuget.csproj...
C:\Dev\TestNuget\TestNuget\TestNuget.csproj : error NU1101: Unable to find package ______.Client. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages, nuget.org [C:\Dev\TestNuget\TestNuget.sln]
  Restore failed in 556.43 ms for C:\Dev\TestNuget\TestNuget\TestNuget.csproj.

Build FAILED.

C:\Dev\TestNuget\TestNuget\TestNuget.csproj : error NU1101: Unable to find package ______.Client. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages, nuget.org [C:\Dev\TestNuget\TestNuget.sln]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.19

user@desktop MINGW64 /c/Dev/TestNuget (master)
$ dotnet restore
  Restoring packages for C:\Dev\TestNuget\TestNuget\TestNuget.csproj...
C:\Dev\TestNuget\TestNuget\TestNuget.csproj : error NU1101: Unable to find package ______.Client. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages, nuget.org [C:\Dev\TestNuget\TestNuget.sln]
  Restore failed in 579.86 ms for C:\Dev\TestNuget\TestNuget\TestNuget.csproj.

user@desktop MINGW64 /c/Dev/TestNuget (master)
$ dotnet restore --configfile nuget.config
  Restoring packages for C:\Dev\TestNuget\TestNuget\TestNuget.csproj...
C:\Dev\TestNuget\TestNuget\TestNuget.csproj : error NU1100: Unable to resolve '______.Client (>= 0.1.8-beta)' for '.NETCoreApp,Version=v2.1'. [C:\Dev\TestNuget\TestNuget.sln]
  Restore failed in 182 ms for C:\Dev\TestNuget\TestNuget\TestNuget.csproj.

user@desktop MINGW64 /c/Dev/TestNuget (master)
$ 

Looks like it was a user error. The package sources in the nuget.config should not have been nested under the config xml tags.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM