uninstall nugetpackage datatables - nuget

I installed jquery.datatables package but something got wrong. So i wanted to uninstall it and try to install it again. In nuget manager there is now way to uninstall it? The usuall button isn't there as for the other packages. So i tried to uninstall the package using the console:
uninstall-package jquery.datatables
It says install completed but when i try to install it again it says that its already there.
How can i completly remove it?
Is there something i can type in the console or can i restart or unistall the nuget manager in some way?

My guess is that NuGet left the package in your packages directory. You could try manually removing the NuGet package.
Remove the jquery.datatables from the packages.config file.
Remove the packages\jquery.datatables.1.9.4 directory and any files it contains.
Remove any files the jquery.datatables NuGet package added to your project.
You could also try the -reinstall option that is available with the Update-Package command:
Update-Package –reinstall <packageName>

Related

Nuget Package restore Added Package is not restored

I am trying to install NuGet Packages with command line, because in Visual studio I get errors, that Visual Studio can't access some nuget Dlls because a proccess is accessing them.
So I've used this command line to install the Packagages from my sln
nuget.exe reinstall -Force c:\GIT\Sales.Bazar\Sales.Bazar.sln
that runns without any problem, but Not all of my NuGet packages are getting installed.
in the commandline Output I can see for example
Restoring NuGet package Ninject.3.2.2.
Adding package 'Ninject.3.2.2' to folder 'c:\GIT\Sales.Bazar\packages'
But when I take a look in my packages folder, there is no such package stored
I dont know what I am missing that the packages are not showing up
when I am changing my nuget command line to this and adding the -NoCache option
nuget.exe reinstall -Force -NoCache c:\GIT\Sales.Bazar\Sales.Bazar.sln
all packages are getting downloaded into my Package folder.

Nuget Package Manager showing updates for packages not installed

When I go to update in Nuget it shows packages that arent installed anywhere in the project. I do a search for say "SimpleJson", nothing in the project is referencing it. How can I get rid of this from the update list?
Try using the Uninstall-package SimpleJson command. It should delete any "ghost" references in your solution.

How do I delete NuGet packages that are not referenced by any project in my solution?

Somehow during the upgrade to VS2012 and .NET 4.5, I've managed to get NuGet confused. There are packages that appear in the package manager (and the packages folder) that I cannot delete (I believe they are legacy ASP.NET NuGet packages that have been replaced with new package names with the new version. They each have only a Manage button -- but no uninstall button. And when you look to see where they are used, you can see that they are referenced by none of the solution's projects? They are NOT displaying an Uninstall?
I've found a workaround for this.
Enable package restore and automatic checking (Options / Package Manager / General)
Delete entire contents of the packages folder (to Recycle Bin if you're nervous!)
Manage Nuget Packages For Solution
Click the restore button.
NuGet will restore only the packages used in your solution. You end up with a nice, streamlined set of packages.
You can use Package Manager Console with command: Uninstall-Package PackageId to remove it, or just delete package folder from 'packages' folder under solution folder.
More information about Package Manager Console you can find here: http://docs.nuget.org/docs/reference/package-manager-console-powershell-reference
First open the Package Manager Console. Then select your project from the dropdown list. And run the following commands for uninstalling nuget packages.
Get-Package
for getting all the package you have installed.
and then
Uninstall-Package PagedList.Mvc
--- to uninstall a package named PagedList.MVC
Message
PM> Uninstall-Package PagedList.Mvc
Successfully removed 'PagedList.Mvc 4.5.0.0' from MCEMRBPP.PIR.
If you want to delete/uninstall Nuget package which is applied to multiple projects in your solutions then go to:
Tools-> Nuget Package Manager -> Manage Nuget Packages for Solution
In the left column where is 'Installed packages' select 'All', so you'll
see a list of installed packages and Manage button across them.
Select Manage button and you'll get a pop out, deselect the checkbox across project name and Ok it
The rest of the work Package Manager will do it for you.
VS2019 > Tools > Options > Nuget Package Manager > General > Click on "Clear All Nuger Cache(s)"
If you have removed package using Uninstall-Package utility and deleted the desired package from package directory under solution (and you are still getting error), just open up the *.csproj file in code editor and remove the tag manually. Like for instance, I wanted to get rid of Nuget package Xamarin.Forms.Alias and I removed these lines from *.csproj file.
And finally, don't forget to reload your project once prompted in Visual Studio (after changing project file). I tried it on Visual Studio 2015, but it should work on Visual Studio 2010 and onward too.
Hope this helps.
An alternative, is install the unused package you want to delete in any project of your solution, after that, uninstall it and Nuget will remove it too.
A proper uninstaller is needed here.
Solution 1
Use the powershell pipeline to get packages and remove in single statement like this
Get-Package | Uninstall-Package
Solution 2
if you want to uninstall selected packages follow these steps
Use GetPackages to get the list of packages
Download Nimble text software
Copy the output of GetPackages in NimbleText(For each row in the list window)
Set Column Seperator to ( if required
Type Uninstall-Package $0 (Substitute using pattern window)
Copy the results and paste them in Package Manage Console
That be all folks.
One NuGet package can reference another NuGet package. So, please be very careful about inter-package dependencies. I just uninstalled a Google map package and it subsequently uninstalled underlying packages like Newtonsoft, Entity Framework, etc.
So, manually deleting particular package from packages folder would be safer.
From the Package Manager console window, often whatever command you used to install a package can be used to uninstall that package. Simply replace the INSTALL command with UNINSTALL.
For example, to install PowerTCPTelnet, the command is:
Install-Package PowerTCPTelnet -Version 4.4.9
To uninstall same, the command is:
Uninstall-Package PowerTCPTelnet -Version 4.4.9
If you want to use Visual Studio option, please see How to remove Nuget Packages from Existing Visual Studio solution:
Step 1:
In Visual Studio, Go to Tools/NuGet Package Manager/Manage NuGet Packages for Solution…
Step 2:
UnCheck your project(s) from Current solution
Step 3:
Unselect project(s) and press OK

Nuget Command Line - Packages Being Installed But Not Added As a Reference in the Project

I am installing all my packages in a project using the following nuget command line command:
nuget install packages.config -o ..\packages
Everything is fetched correctly and added to the packages, yet no references are added to the project. If right click the solution folder and select to manage the nuget packages, I can see the packages installed in the project yet there are no references added for the next packages?
Am I missing a step here?
This is by design. We never modify the project file from outside of VS. The command you're running is basically "restore my packages folder" and should be used with this workflow http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages.

How do I get NuGet to install/update all the packages in the packages.config?

I have a solution with multiple projects in it. Most of the third party references are missing, yet there are packages.config file for each project. How do I get NuGet to install/update all the packages needed? Does this need to be done via command line for each project?
You can use nuget.exe to restore your packages or with NuGet 2.7, or above, installed you can simply compile your solution in Visual Studio, which will also restore the missing packages.
For NuGet.exe you can run the following command for each project.
nuget install packages.config
Or with NuGet 2.7 you can restore all packages in the solution using the command line.
nuget restore YourSolution.sln
Both of these will pull down the packages. Your project files will not be modified however when running this command so the project should already have a reference to the NuGet packages. If this is not the case then you can use Visual Studio to install the packages.
With NuGet 2.7, and above, Visual Studio will automatically restore missing NuGet packages when you build your solution so there is no need to use NuGet.exe.
To update all the packages in your solution, first restore them, and then you can either use NuGet.exe to update the packages or from within Visual Studio you can update the packages from the Package Manager Console window, or finally you can use the Manage Packages dialog.
From the command line you can update packages in the solution to the latest version available from nuget.org.
nuget update YourSolution.sln
Note that this will not run any PowerShell scripts in any NuGet packages.
From within Visual Studio you can use the Package Manager Console to also update the packages. This has the benefit that any PowerShell scripts will be run as part of the update where as using NuGet.exe will not run them. The following command will update all packages in every project to the latest version available from nuget.org.
Update-Package
You can also restrict this down to one project.
Update-Package -Project YourProjectName
If you want to reinstall the packages to the same versions as were previously installed then you can use the -reinstall argument with Update-Package command.
Update-Package -reinstall
You can also restrict this down to one project.
Update-Package -reinstall -Project YourProjectName
The -reinstall option will first uninstall and then install the package back again into a project.
Or, you can update the packages using the Manage Packages dialog.
Updates:
2013/07/10 - Updated with information about nuget restore in NuGet 2.7
2014/07/06 - Updated with information about automatic package restore in Visual Studio and brought the answer up to date with other changes to NuGet.
2014/11/21 - Updated with information about -reinstall
Open Package Manager Console
View -> Other Windows -> Package Manager Console
Reinstall all packages in ALL PROJECTS of the current solution:
Update-Package -Reinstall
Reinstall all packages in SPECIFIC PROJECT of the current solution (Thanks to unarity and ashes999):
Update-Package -ProjectName 'YourProjectNameGoesHere' -Reinstall
There is another, newer and quicker way to do this from within Visual Studio. Check out this post by David Ebbo, and reference the comments section if you run into trouble. Basically, you do the following in Package Manager prompt:
PM> Install-Package NuGetPowerTools
PM> Enable-PackageRestore
Afterwards, when you build your solution the packages will be automatically installed if they're missing.
Update:
This functionality is built into Nuget 1.6 with visual studio integration so you don't even need to install NuGetPowerTools or type commands. All you have to do is
Right click on the Solution node in Solution Explorer and select
Enable NuGet Package Restore.
Read this article for more details.
Here's another solution if you are using website projects, or don't want to enable NuGet Package restore.
You can use the package manager console to enumerate all the packages in the package.config file and re-install them.
# read the packages.config file into an XML object
[xml]$packages = gc packages.config
# install each package
$packages.packages.package | % { Install-Package -id $($_.id) -Version $($_.version) }
Update-Package -ProjectName 'YourProjectNameGoesHere' -Reinstall
This is best and easiest example I found. It will reinstall all nugets that are listed in packages.config and it will preserve current versions. Replace YourProjectNameGoesHere with the project name.
With the latest NuGet 2.5 release there is now an "Update All" button in the packages manager: http://docs.nuget.org/docs/release-notes/nuget-2.5#Update_All_button_to_allow_updating_all_packages_at_once
I'm using visual studio 2015 and the solutions given above didn't work for me, so i did the following:
Delete the packages folder from my solution and also bin and obj folders from every project in the solution and give it a rebuild.
Maybe you will have the next error:
unable to locate nuget.exe
To solve this: Change this line in your NuGet.targets file and setting it to true:
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">true</DownloadNuGetExe>
Reference:https://stackoverflow.com/a/30918648 and https://stackoverflow.com/a/20502049
After 3 hours of searching and investigation.
I had problems with it because we have two members in team (using GitHub source control), because we didn't restrict files for packages for sending to remote repository, one of team members was send packages to server and i have pull that changes to my local.
After that i had same problem as PO, also i wasn't be able to publish my API project to server.
At the and I have just used
Update-Package -Reinstall - run this command on Package Manager Console
This command will reinstall all your packages that you have used in your solution. (For every project)
Reinstall all packages in ALL PROJECTS of the current solution:
Update-Package -ProjectName 'NameOfProject' -Reinstall - run this command on Package Manager Console
This command will reinstall all your packages that are in relation with project that you specified after "-ProjectName". And i think that this is better because i had wait for half a hour to reinstall all packages in solution.
For this many thanks to Rodolpho Brock.
Also, I would recommend you that when you pull changes from remote server, to press "Restore packages" button that will be shown by Visual studio.
I believe the first thing you need to do is enable the package restore feature. See also here. This is done at the solution (not project) level.
But that won't get you all the way -- I ran into a similar issue after having enabled the restore feature. (VS2013, NuGet 2.8.)
It turned out I had (unintentionally) committed the packages to source control when I committed the project -- but Visual Studio (and the source control plugin) had helpfully ignored the binaries when performing the check-in.
The problem arose when I created a release branch. My local copy of the dev/main/trunk branch had the binaries, because that's where I had originally installed/downloaded the packages.
However, in the new release branch,
the package folders and .nupkg files were all there -- so NuGet didn't think there was anything to restore;
but at the same time, none of the DLLs were present -- i.e. the third-party references were missing -- so I couldn't build.
I deleted all the package folders in $(SolutionDir)/packages (under the release branch) and then ran a full rebuild, and this time the build succeeded.
... and then of course I went back and removed the package folders from source control (in the trunk and release branch). I'm not clear (yet) on whether the repositories.config file should be removed as well.
Many of the components installed for you by the project templates -- at least for web projects -- are NuGet packages. That is, this issue is not limited to packages you've added.
So enable package restore immediately after creating the project/solution, and before you perform an initial check-in, clear the packages folder (and make sure you commit the .nuget folder to source control).
Disclaimer: I saw another answer here on SO which indicated that clearing the packages folder was part of the resolution. That put me on the right track, so I'd like to give the author credit, but I can no longer locate that question/answer. I'll post an edit if I stumble across it.
I'd also note that Update-Package -reinstall will modify the .sln and .csproj/.vbproj files. At least that's what it did in my case. Which IMHO makes this option much less attractive.
For those arriving here due to the build server falling foul of this, you can create an MSBuild target running the exec command to run the nuget restore command, as below (in this case nuget.exe is in the .nuget folder, rather than on the path), which can then be run in a TeamCity build step immediately prior to building the solution
<Target Name="BeforeBuild">
<Exec Command="..\.nuget\nuget restore ..\MySolution.sln"/>
</Target>
If you Nuget 2.8 install, check the checkbox
Tools >> Nuget Manager >> Package Manager Settings >> Automatically check for missing packages during build
in Visual Studio. If it is checked, then simply rebuild the project will restore all your reference libraries.
I tried Update-Package -reinstall but it fails on a package and stopped processing all remaining packages of projects in my solution.
I ended up with my script that enumerates all package.config files and run Update-Package -Reinstall -ProjectName prj -Id pkg for each project/package.
Hope it can be useful for someone:
$files = Get-ChildItem -Recurse -Include packages.config;
[array]$projectPackages = #();
$files | foreach { [xml]$packageFile = gc $_; $projectName = $_.Directory.Name; $packageFile.packages.package.id | foreach { $projectPackages += #( ,#( $projectName, $_ ) ) } }
$projectPackages | foreach { Update-Package -Reinstall -ProjectName $_[0] -Id $_[1] }
Edit:
This is an error that I had:
Update-Package : Unable to find package 'EntityFramework.BulkInsert-ef6'. Existing packages must be restored before performing an install or update.
Manual run of
Update-Package -Reinstall -ProjectName my_prj -Id EntityFramework.BulkInsert-ef6
worked very well.
now Nuget Package Manager Console in Visual Studio 2012 gives you a "Restore" button automatically as soon it find any package not installed but in there in package.config.
Awesome Feature!
At VS2012 V11, if I use "-Reinstall" at the end of the line it doesn't work.
So I simply used:
Update-Package -ProjectName 'NAME_OF_THE_PROJECT'
I know this is an old post, but thought this could be useful. If you have a need to ignore specific packages during the update process (like any packages that update JavaScript references), use the following PowerShell script (make sure your package source is set to "All" in Package Manager Console):
EDIT 2014-09-25 10:55 AM EST - Fixed a bug in the script
$packagePath = "packages.config"
$projectName = "MyProjectName"
$packagesToIgnore = #(
"bootstrap",
"jQuery",
"jquery-globalize",
"jquery.mobile",
"jQuery.jqGrid",
"jQuery.UI.Combined",
"jQuery.Validation",
"Microsoft.jQuery.Unobtrusive.Validation",
"Modernizr",
"Moment.js"
)
[xml]$packageFile = gc $packagePath
$packagesToProcess = $packageFile.packages.package | Where-Object {$packagesToIgnore -notcontains $_.id}
$packagesToProcess | % { Update-Package -reinstall -projectname $projectName -id $($_.id) }
Don't know since when, but in VS2019 you can do it in an easier way:
right click solution in Solution Explorer
select Manage Nuget Packages for Solution
there are 4 tabs, Browse, Installed, Updates, Consolidate
the Consolidate shows if there is any projects using different version of packages (and in most cases, that's why we want to update all the packages)
the Updates shows if there is any update available in ANY projects. Select all and click update, the job will be done.
In Visual Studio 2017 - When you compile using IDE - It will download all the missing nuget packages and save in the folder "packages".
But on the build machine compilation was done using msbuild.exe. In that case, I downloaded nuget.exe.
During each build process before executing msbuild.exe. It will execute -> nuget.exe restore NAME_OF_SLN_File (if there is only one .SLN file then you can ignore that parameter).