2

I'm new to Nuget and would like to know how to incorporate it to my work projects. I packaged a couple of dll's and created a local nuget feed. I added it to my visual studio, which I see with all the packages in it. I made sure to click the 'Automatically check for missing packages during build in Visual Studio' and the 'Allow NuGet to download missing packages' options, but when I build my project it's not automatically adding the missing dll references. I also tried the 'restore nuget package' option when I right click my solution, but it just tells me that everything was restored even though I don't see it. Also, I read that it's suppose to create a .nuget, nuget.target, and a nuget.config but I don't see it in my solution. Can someone tell me what am I doing wrong or missing? and how I can fix this issues.

I'm trying to do this in Visual Studio 2015, but will later try it on previous versions.

Dale K
  • 25,246
  • 15
  • 42
  • 71
OiC
  • 47
  • 1
  • 8
  • Have you added the actual packages to your project? Just adding the feed isn't enough... it's not like it's going to add everything in the feed to every project. – Jon Skeet May 18 '17 at 03:55

1 Answers1

1

Can someone tell me what am I doing wrong or missing? and how I can fix this issues.

First, Just as Jon commented, you should make sure you have add the packages to your project. You can do this by Package Manager Console or Manage NuGet Packages UI.

Second, If you still have this issue after installed the packages to your project, you should use the NuGet command line in the Package Manager Console:

Update-Package -reinstall

to force reinstall the package references into project. Because NuGet Restore only restores files in the packages directory (\packages folder ), but does not restore files inside your project or otherwise modify your project.

I read that it's suppose to create a .nuget, nuget.target, and a nuget.config but I don't see it in my solution.

This restore method is for MSBuild-integrated restore with NuGet 2.6 and earlier, With NuGet 2.7 and later, Visual Studio automatically restores missing packages by default at the beginning of a build. This behavior can be changed by clearing Tools > Options > [NuGet] Package Manager > General > Automatically check for missing packages during build in Visual Studio.

Since you are using Visual Studio 2015, the default version of NuGet is 3.x, that restore method does not apply to your issue, just make sure click the 'Automatically check for missing packages during build in Visual Studio' and the 'Allow NuGet to download missing packages' options.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • So I have to manually add each package I need to the project first, then next time that package is run let say it tfs, it will automaticall pick up the missing dll's? I thought as long as the dll was referenced before it will automatically find it in the nuget feed if it's missing. – OiC May 18 '17 at 15:08
  • @MikeT, If you branch from TFS, nuget will restore the packages automatically, the references may broken by some reasons, you can use simple command to re-install them. http://stackoverflow.com/questions/42775876/nuget-packages-are-there-but-missing-references/42778916#42778916. If above answer resolve your question, you can mark it answer, so it could help other community members who get the same issues. If not, let us to know the latest status of this question. If you have more question, you can submit another post, we will also follow it up. – Leo Liu May 19 '17 at 06:01