Search code examples
visual-studiovisual-studio-2012nugetnpgsql

Why can I install NuGet v4.0.10 in VS2019 but not in VS2012?


I want to get Npgsql for a project targeting .Net 4.5 in Visual Studio 2012. It appears the latest Npgsql version supporting that version of .Net is 4.0.10. In Visual Studio 2012, with package source set to nuget.org, I got the following:

PM> Install-Package Npgsql -Version 4.0.10
Install-Package : Unable to find version '4.0.10' of package 'Npgsql'.
At line:1 char:16
+ Install-Package <<<<  Npgsql -Version 4.0.10
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

But in Visual Studio 2019, with the same source, the package was installed successfully. What do I have to do to install it in my VS2012 project?


Solution

  • But in Visual Studio 2019, with the same source, the package was installed successfully. What do I have to do to install it in my VS2012 project?

    First, thanks to Lex for sharing the useful info with us.

    Since VS2012 is too old to maintain it, the highest version of Nuget in VS2012 is v2.8.60318.667. And Npgsql 4.0.10 needs nuget v4.xxx or above which is not supported in VS2012.

    enter image description here

    enter image description here

    Solution

    If you want to install this nuget package in VS2012, you cannot install the latest version(4.0.10) of the Npgsql nuget package, you should install the version which nuget v2.8.60318.667 supports.

    And Npgsql 3.1.10 is supported in VS2012 which l have tested successfully.

    1) If the nuget version in VS2012 is not the latest, you should update nuget version to the latest v2.8.60318.667. (Tools-->Extensions and Updates-->Updates)

    2) Open Package Manage Console by Tools-->Nuget Package Manager-->Package Manager Console and type this:

    Install-Package Npgsql -Version 3.1.10
    

    Update

    Just install an old version of Npgsql (<=3.1.10)

    Hope it could help you.