Search code examples
visual-studionuget

NuGet search shows package available but install says it's not found


I'm trying to get jQuery-vsdoc. Find-Package jQuery-vsdoc returns what I expected. But Install-Package jQuery-vsdoc state it's unavailable.

How can Find-Package work but Install-Package says it's not found?

Isn't Find-Package supposed to only show what can be found?

This is exact output from the package console

PM> Find-Package jQuery-vsdoc

Id                                  Versions                                 Description                                                                     
--                                  --------                                 -----------                                                                     
jQuery-vsdoc                        {2.1.0}                                  jQuery IntelliSense for Visual Studio.                                          
JQStart                             {1.0.4}                                  This NuGet package contains: jquery-1.6.2-vsdoc.js, start.debug.js, start.js....
Time Elapsed: 00:00:00.2826224


PM> Install-Package jQuery-vsdoc


Attempting to gather dependency information for package 'jQuery-vsdoc.2.1.0' with respect to project 'MyCorp.Moma.Mia.Web', targeting '.NETFramework,Version=v4.5.1'
Install-Package : Package 'jQuery-vsdoc 2.1.0' is not found in the following primary source(s): 'https://api.nuget.org/v3/index.json'. Please verify all 
your online package sources are available (OR) package id, version are specified correctly.
At line:1 char:1
+ Install-Package jQuery-vsdoc
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
 
Time Elapsed: 00:00:00.2765972
PM> 

Screen shot of nuget package manager


Solution

  • Based on my test, i found that this jQuery-vsdoc package not only supports .NET SDK but also .NET Framework.

    1.Target .NET Framework that uses packages.config by default.

    enter image description here

    2.Target .NET that uses PackageReference.

    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
         <TargetFramework>net8.0</TargetFramework>
      </PropertyGroup>
      <ItemGroup>
        <PackageReference Include="jQuery-vsdoc" Version="2.1.0" />
      </ItemGroup>
    

    enter image description here

    For this issue, here are suggestions you can troubleshoot:

    1.Clear Nuget Storage. Go to Tools > NuGet Package Manager > Package Manager Settings. In the settings dialog, click on Clear All NuGet Storage.

    2.Try to install other nuget packages for test and confirm if this issue only occurs with a specific package or all packages.

    3.Ensure that your internet connection is stable and you have access to nuget website.

    4.Try to download the package directly from nuget website and put the package into your local folder then install this package from local folder to see if you can install this package successfully. enter image description here