This project references NuGet package(s) that are missing on this computer

后端 未结 19 1348
南方客
南方客 2020-11-28 00:29

I have an ASP.NET MVC5 application that worked yesterday and now I am getting this error when I try to build:

This project references NuGet package(s)

相关标签:
19条回答
  • 2020-11-28 01:34

    Editing .sln and .csproj is not always that easy or desirable. Once you get the error list you can see what projects have missing packages (also, the References node usually indicate that there are missing assemblies unless packages are source code, resources, images, or just text-based ones).

    Removing and then adding the packages is not a good idea unless you use the latest version of the package. Otherwise be prepared for surprises, not always pleasant ones.

    If, say, the package is EntityFramework then from NuGet gallery you get the latest version which at the time of writing this comment it is 6.1.3.

    So, maybe the safest way to handle the situation is to restore the missing packages one by one. Yes, a bit painful exercise but chasing subtle bugs due to different package version maybe much more unpleasant.

    Having this said, and let again EntityFramework be the missing package, you can issue the following command in the Package-Manager Console:

    PM> Install-Package EntityFramework -Version 6.0.1 
    

    This will install the correct version, that is 6.0.1, that is the one that is specified in packages.config:

        <?xml version="1.0" encoding="utf-8"?>
        <packages>
          <package id="EntityFramework" version="6.0.1" targetFramework="net451" />
        </packages>
    
    0 讨论(0)
提交回复
热议问题