Nuget does not update package links on ASP.NET

A: I have an ASP.NET website (not a web project) with 3 library projects in this solution. I used to use SVN , but now Git is used. I installed git locally on a computer (used as a server) and used it to merge the source code with other developers. In addition, I am using Visual Studio 2015 Community Edition, which provides tools for working with git.

Problem: After cloning a project from the main repository, I create a project to run it. Building a project shows a dialog box that says "Package recovery." This process creates a folder called Packages, and this folder includes all the packages listed in the packages.config file. But after the restoration is complete, the project throws the following exception:

This exception is displayed for each package (here Autofac).

Could not find Autofac namespace name or name (are you missing the using directive or assembly references?)

Work . To solve this problem, I need to remove every package and install it again, and the problem is solved. This is the thing that I have to do over and over for every machine for developers, which is also frustrating and time consuming.

Has anyone encountered the same issue related to Nuget, git and the ASP.NET website.

+6
source share
4 answers

It’s good practice not to put third-party packages in the original control. It inflates your repository (even in a large web application, the size of external packages will massively weigh your code).

If restoring a NuGet package is slow, you can look at using a local cache (it can be as simple as a shared folder) or a better Internet connection.

However, you should have this problem only once per machine. While the packages are loading, you can give the new team member a design overview ...

+2
source

I ran into the same problem as before. In my case, the reason was that I changed the project path (moved the project to another directory), and the path to the package directory (which contains the NuGet packages) was saved in the csproj file for the old path, that is, VS cannot restore the NuGet packages . The solution for this was to edit csproj manually and make it a link to the correct path of the new packages.

If this does not work for you, you can still use your workaround, but for simplicity, use the following PowerShell command (in the NuGet console):

Update-Package -reinstall -Project Your.Project.Name 

Note: the project name does not contain the csproj extension, just the project name

+1
source

Make sure all your projects use the same target structure, when this is not done, you can often get type or namespace [name] could not be found warning.

To do this, right-click each of the projects in Solution Explorer> Properties> Application tab> Target Structure. All of them must be the same or will be incompatible between the links in your projects. Here is a question on this issue, I hope this helps.

0
source

The main reason is the lack of an Autofac link in the packages.config file. When you see the "Restore packages" message on the screen, it means that the nuget package manager is trying to install all packages that are not in the package folder. Try this step:

  • In the Visual Studio Solution Explorer, select the project and select "Unload Project" from the context menu
  • After the project has been downloaded via the context menu, select "Edit your project"
  • Go to the section section and find the Autofac help section
  • If HintPath doesn't look like this. \ packages \ Autofac.4.1.1 \ lib \ net45 \ Autofac.dll (Actually for version 4.1.1) removes the link to the Autofac help element.
  • Save the csproj file and reload the project
  • Install Autofac Using NuGet Package Manager
  • Commit and push changes to git repository
0
source

All Articles