MVC Nuget Installing Multiple Packages - asp.net-mvc

I'm building a new solution/project. I copied all the files over and moved all the packages over to the packages folder. When I reference them via nuget, it says they are installed, but
they are not. If they were, I would see them in the installed tab.
First why does it say installed, next how can I install multiple packages at once, instead of
doing it individually. I have like 10+ packages I need to install. This is pain in
the ass, if I have to install each individually. We should be able to run a command that
checks to see if all the packages in the package folder have been installed, if not, install them. Is there a command for this?

Use nuget.exe for this. see following question and google search
nuget install packages.config
Or with NuGet 2.7 you can restore allpackages in the solution using the command line.
nuget restore YourSolution.sln

Related

Update Packages of a MVC Project

Im trying to use an ASP.NET web application downloaded from the internet. Im looking for a way restore all the dependencies/packages in a quick way (clean and building the project did not solve it), rather than installing them via nuget one by one. Is there anyway to download and install/resolve (version issues) all the necessary packages at once?
I tried below package manager console commands, but they did not resolve the package conflicts.
Update-Package -Reinstall,
nuget install packages.config and other solutions here - How do I get NuGet to install/update all the packages in the packages.config?
[resolve/install packages]
Can someone help? Maybe Im using wrong commands or doing something wrong.
If you go into Tools > Nuget Package Manager > Manage Nuget Packages for Solution, it will show a yellow bar at the top asking you if you want to restore missing packages. That's a manual way, but there are also some important VS options you want to look at as well, one being an option to restore packages on build.
There is a generic restore option as well from the package manager console, and that should have worked if it was simply a matter of reimporting the missing packages...
Update-Package -reinstall
You can try to delete the folders, than reinstall using these options. However, is there a possibility there is a .NET framework version mismatch with the version of the DLL's? Maybe some of the DLL's need updated?
Remove package folders from Package folder - don't remove package.config. Next, build you application - nuget should automatically restore all packages.

TFS does not allow the NuGet packages to be installed/Updated

I am in VS2015/TFS environment and I have been having this constant issue with TFS Source Control:
Every time I want to install the package, it fails with following error
Install failed. Rolling back... Package 'jQuery.Cookie 1.4.1' does not
exist in project 'Web'
This is the same exact error that I see every time I try to install any of the packages.
Currently, I have been taking a copy of my project folder and then put it somewhere where I do not have any SourceControl, then I install the package and copy it back to its original location
The only problem with this approach is that it is a lot of tedious work everytime I want to install a new package
Also, all the packages installed in this manner are not recognized by the source Control and that is why I have to add each file saperately. Not to mention that since it is not as accurate as having Nuget taking care of everything for me, sometimes I miss to check in some of the files and it breaks things on the server.
Can someone guide me on how can I smoothly install an new NuGet package on VS 2015 without having to go through this tedious process?
It seems to be caused by the bug in old nuget version: Install package fails when solution/project is bound to TFS source control
Update nuget to latest version and then try again.

VisualStudio 2013 list all NuGet packages

I have a mvc 5 web project with a number of NuGet packages installed (like email, log, pagedlist etc).
In a new similar project I would like to install the same NuGet packages. How can I in the old project list all installed NuGet packages?
You can find a packages.config file in the old project's root directory.
You can copy it to the new project.
If you go to Tools -> NuGet Packet Manager -> Packet manager settings and check Allow NuGet to download missing packages and the other check box that states Automatically check for missing packages during build in Visual Studio it will download it for you next time you build.
If you want to list all installed nuget packages for the project take a look at this one.
http://blogs.msdn.com/b/david_kidder/archive/2014/08/19/micro-blog-how-to-list-installed-nuget-packages-from-package-manager-console-and-be-able-to-read-them.aspx
You might also want to enable nuget package restore to restore the packages when rebuilding your project/s.
Here's another link for you - http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html
In the root folder of your original project find a packages.config file. Copy its contents to your new project, same file name.
Go to Visual Studio > Tools > Package Manager Settings > General
Enable "Allow Nuget to download..." and "Automatically check for missing..."
Now build your new project
Most of the answers here are partially correct.
The first part is true. The packages.config file lists all packages that are used by the project.
However, all the answers about using Package Restore are incorrect. Package Restore will download any missing packages, however it is NOT the same as installing a package into a project. It will not add references, run any install.ps1 scripts, or add files, modify .config, etc. Package Restore simply downloads missing packages. It is assumed that the packages were already installed to the project.
In order for the packages to be correctly installed in your new project, open the Package Manager console, then type:
Update-Package -ProjectName MyProjectName -Reinstall
This will force NuGet to run through the install process and correctly install the package into your project.

NuGet doesn't show installed packages

I have MVC 5 project and I use NuGet to install packages. Yesterday I have installed a couple of packages, but today when I run my application I got an error of missing references. I've realized, that my project doesn't have any of references and files that were added from NuGet.I have all this packages in packages folder in my app, but no records about this packages in packages.config file. If I click Manage NuGet Packages in my solution explorer, in online search it shows me all my packages as installed, but in all installed tab it doesn't show me any of them! I didn't do anything since yesterday? What could happened and how to fix all my packages?
I have had this happen from time to time. There are two things that you can try:
Right click your solution in 'Solution Explorer' and select 'Enable NuGet Package Restore'
Close and Reopen VS
Try Rebuild
Otherwise, just uninstall/reinstall each package.
Hope that helps!
Sometime you added new package does't support to your .net framework which is currently active, so active related .net framework as well.
I just have experienced the same problem. In my case, two different versions of a sample package in the packages.config file causing the problem. After removing the older version of the package from the file, VS shows the list normally.

Why does NuGet check out all csproj-files in TFS on update-package?

I have a solution with multiple projects, many of the projects have NuGet packages installed, some of them have the same packages installed. When I run update-package NuGet checks out every csproj-file and occasioanlly it also adds some app.config file to some projects.
Did those projects actually get updated? If so then the csproj file will get updated. app/web.config gets added if a package adds it or if you need binding redirects for the packages to work together.

Resources