How do I fix this NuGet Restart loop in Visual Studio 2017? - visual-studio

The NuGet prompt, "Multiple packages failed to uninstall. Restart Visual Studio to finish the process," appears repeatedly in Visual Studio 2017 no matter how many times I restart the application.
I'm selecting Tools > NuGet Package Manager > Manage NuGet Packages For Solution. Then this dialog appears.
We have a solution in VS 2017 with multiple NuGet package references which will not resolve. A colleague added these references, but when I load the solution they show up with the yellow triangles in the "bin" directory in Solution Explorer.
The missing references are for .pdb and .xml files. These problems started occurring after Visual Studio 2017 was reinstalled on my PC.
Really, I don't want to remove the references. I want them to resolve. And I want to get out of this NuGet Restart loop. Perhaps my NuGet package manager settings need to be adjusted, or I need to use the NuGet Command Prompt to fix this. Just don't know the next steps. Thanks for your help.

How do I fix this NuGet Restart loop in Visual Studio 2017?
It seems this nuget package is locked by other process, like File Explorer.
To resolve this issue, close all the Visual Studio instance first, then try to delete the \packages folder in the solution folder and delete the \bin folder manually. If you project type is .net core/.net standard, you need to clear the packages cache:
# Clear all caches (use either command)
dotnet nuget locals all --clear
nuget locals all -clear
Do not forget to restart the PC after above operations.
Check the document Clearing local folders for some more details.
Besides, do not worry those references will be removed, when you build the project, nuget will restore those package, and if find any reference missing, just execute NuGet command line in the Package Manager Console:
Update-Package -reinstall
NuGet will reinstall those packages and add references to the project.
Check the similar thread for some more details.
Hope this helps.

Related

Visual Studio 2017 froze while installing Nuget package and now my Xamarin project doesn't load

I tried to install Xamarin.Android.Support.Annotations 28.0.0 only to the Android part of my Xamarin Forms project.
There's a popup with:
Microsoft Visual Studio is busy
We'll automatically report this delay to Microsoft...
No matter how long I wait, I can't open the project. What do I have to do to clear the cache to be able to load my project again?
What do I have to do to clear the cache to be able to load my project again?
To clear the nuget cache, you can download the NuGet command line tool from nuget.org.
Then, open a command prompt and cd to the directory to where nuget.exe is located.
You can list the local caches with this command:
nuget locals all -list
You can clear all caches with this command:
nuget locals all -clear
Check more info: Managing the global packages, cache, and temp folders.
Note: If your Visual Studio is not the latest version, please try to update it, MS fixed this issue on the some newer version.
Hope this helps.

Error while adding NuGet Package

I am getting the following exception while adding NuGet package to project. I am using the latest version of Visual Studio 2017 Pro.
try going to VS settings -> NuGet settings -> clear the NuGet cache, close Visual Studio, and delete all obj and bin folders in solutions .
Error while adding NuGet Package
AFAIK, It seems an issue which needs to be fixed from Xamarin team and someone already reported it:
https://bugzilla.xamarin.com/show_bug.cgi?id=61113
You can track this thread to get future updates for this issue.
Here are some of the workarounds already mentioned in that thread:
Update the packages with the option -IgnoreDependencies in the Package Manager Console (It works for me):
Update-Package -IgnoreDependencies
Update Visual Studio to latest version and running as Administrator
Some of the files in the packages folder were set to read-only. Try to cleare the read-only flag from all files in the packages folder.
Hope this helps.
I tried a lot of ways to solve this problem. But unfortunately cleaning the cache, project, rebuilding didn't help. The only thing I didn't try is to re-install Visual Studio or Windows.
I've got to launch project in Visual Studio for Mac and update/add all the necessary Nuget packages from there. On the Mac, the process was successful. I know this might not be an option if you don't have device, but it definitely works.

Visual Studio Online - Get Latest and NuGet

It's very possible that I'm missing something simple because I can't find others on the internet experiencing the same thing.
I'm a team that's new to the use of TFS and Visual Studio Online and we're encountering this problem:
(Using Visual Studio 2015 & 2013)
I used NuGet to add Microsoft.AspNet.WebApi.Cors to my newly created WebAPI project (ditto all other NuGet packages)
Did my work and checked in a building solution in to VSO
Co-worker did a Get Latest
His newly-retrieved project won't build and, when we expand the References, the assemblies are marked with a yellow warning icon, indicating that they're missing
We've tried (from the context of the failing project):
Update-Package
Update-Package -reinstall
Manually uninstalling and reinstalling the package in the NuGet UI
Manually adding the entire contents of the Packages directory in to TFS and doing a get latest on that directory as well
Wiping the solution out from his local file system and pulling it down clean
Copying the contents of my {Solution Directory}\Packages to a USB drive, walking it to my co-worker's computer, and copying it to his machine
Only item #6 worked but I'm CERTAIN that this cannot be the right answer.
I guarantee that this is worthy of a dope-slap but what might I be missing?
Thank you to jessehouwing for reminding me that this topic is still out here. He's exactly right on. We removed the Packages folder from source control and that resolved the problem completely.

Can't Update or Uninstall NuGet Package Manager in VS2012

I am unable to update or uninstall the NuGet Package Manager for Visual Studio 2012. I've looked around to several solutions, but have not found one that works.
Running Visual Studio 2012 as the administrator...
Attempting to update the NuGet Package Manager fails, and I get this error dialog with the following at the end of the log:
2/5/2013 10:38:09 AM - Beginning to install extension to Microsoft Visual Studio Ultimate 2012...
2/5/2013 10:38:09 AM - Upgrading 'NuGet Package Manager', version 2.0.30625.9003 to version 2.2.31210.9045.
2/5/2013 10:38:10 AM - Install Error : System.IO.IOException: The process cannot access the file because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.__Error.WinIOError()
at System.IO.File.InternalMove(String sourceFileName, String destFileName, Boolean checkHost)
at Microsoft.VisualStudio.ExtensionManager.ExtensionManagerService.AtomicallyDeleteFiles(IEnumerable1 filePaths, Boolean justMarkForDeletion)
at Microsoft.VisualStudio.ExtensionManager.ExtensionManagerService.DeleteDiscoverableFiles(IInstalledExtension extension)
at Microsoft.VisualStudio.ExtensionManager.ExtensionManagerService.UninstallInternal(IInstalledExtension extension, Boolean forceDelete)
at Microsoft.VisualStudio.ExtensionManager.ExtensionManagerService.CommitInstalledAndUninstalledExtensions(IEnumerable1 installedExtensions, IEnumerable1 uninstalledExtensions, IEnumerable1 packComponentChanges)
at Microsoft.VisualStudio.ExtensionManager.ExtensionManagerService.BeginInstall(IInstallableExtension installableExtension, Boolean perMachine, AsyncOperation asyncOp)
at Microsoft.VisualStudio.ExtensionManager.ExtensionManagerService.InstallWorker(IInstallableExtension extension, Boolean perMachine, AsyncOperation asyncOp)
Followed by a popup telling me:
The process cannon access the file because it is being used by another process.
When I attempt to uninstall the extension first (per some solutions) I receive the same pop-up message as above, telling me the process is being used!
Steps I've made in my attempts to get this working:
I've restarted VS2012 multiple times, with and without projects loaded.
I've rebooted the computer several times and started nothing other then VS2012.
I've downloaded the NuGet installer from the web and tried to install it w/o starting VS2012 (first thing after reboot).
For step #3, I receive the same series of dialogs/errors as when attempting to update inside Visual Studio 2012.
I can't get the latest version, no matter what I try! Does anyone have another trick?
I've also noticed that NuGet is just plain not working right now. Neither the "Package Manager Console" or the "Package Manager Settings" do anything.
Source:
http://www.paraesthesia.com/archive/2013/07/30/upgrading-nuget-the-process-cannot-access-the-file-because-it.aspx
This is what helped me:
Close all instances of Visual Studio.
Go to your global Visual Studio extensions folder. NuGet doesn’t
install in your per-user folder; instead, you’ll see it in Program
Files. Something like: C:\Program Files (x86)\Microsoft Visual
Studio 11.0\Common7\IDE\Extensions
Look in that folder. You will see a lot of randomly named folders
like “sdjfksiov.djd” and so on. Most (if not all) of those are
NuGet. You’ll want to be aware of which ones are NuGet and which
ones aren’t, particularly if you have other extensions installed.
(You can tell if it's NuGet because it'll have a bunch of
NuGet.*.dll files in there. If you don't see NuGet stuff in there,
you'll want to keep it.)
Rename that Extensions folder to something like: C:\Program Files
(x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions_RENAMED
Download NuGet directly from the Visual Studio extension gallery.
Execute the downloaded NuGet.Tools.vsix file you just downloaded.
Don’t do it through Visual Studio. Just double-click the .vsix file
to install it.
NuGet should successfully install. As part of that install, it will
create the Extensions folder again, so you will once again see
C:\Program Files (x86)\Microsoft Visual Studio
11.0\Common7\IDE\Extensions
Open up your renamed extensions folder and move all of the non-NuGet
extensions into the new Extensions folder.
Now open Visual Studio. You should see the new version of NuGet
installed and working.
You can delete that renamed Extensions folder once you’ve verified
everything is working.
Download VSIX and right click unblock the file and install again
I'm using VS2010, I ended up fixing this problem by uninstalling NuGet Package Manager via the "Add Remove Programs", and then deleting this directory:
C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft Corporation\Nuget Package Manager
I could then run the NuGet.Tools.vsix thing ok.
I have VS 2013 Pro installed. What solved this problem for me was to restart into safe mode and re-install NuGet there.
You may also want to look into Adam D's post in the link below (the add-in was blocked by anti-malware software):
Can't Update or Uninstall NuGet Package Manager in VS2012
I found a solution for this issue at -
https://kc.mcafee.com/corporate/index?page=content&id=KB85636&snspd-1015&locale=en_GB&viewlocale=en_GB
Cause:
The Microsoft Visual Studio (VS) process devenv.exe must be excluded in the EEFF/FRP process exclusion registry key.
Solution:
Users with this issue must contact Intel Security Technical Support and quote this article number for assistance with adding the devenv.exe process to the correct EEFF/FRP process exclusion registry key.

Opening project in Visual Studio fails due to nuget.targets not found error

So I downloaded Twitterizer from http://www.twitterizer.net/downloads/
I try to open it in Visual Studio and get all these nuget errors:
The imported project "C:\Twitterizer\.nuget\nuget.targets" was not found.
Confirm that the path in the <Import> declaration is correct, and that the file
exists on disk.
What is going on. How do I deal with this?
Install Nuget.
Right click on the solution and select "Enable NuGet
Package Restore". In Visual Studio 2013 and later, select "Restore NuGet Packages" instead.
Click Ok on the warning.
Close and re-open the solution.
Should now be hunky-dory.
An alternative is to edit the .csproj file with a texteditor and remove or comment out the segment.
This error normally happens when you are trying to open a .csproj directly, not through the solution file, and the .csproj imports the Nuget targets like this:
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" />
In order to solve it, you can either open the .sln and not the .csproj directly...or remove the import line above.
Notice that the mentioned error will only happen when you are using solution wise package restore, which isn't even recommended anymore.
Just ran into the same problem, but in my case the issue was a space in the folder name:
Nuget was telling me it couldn't find "C:\git\My Path" but I was able to navigate to "C:\git\My%20Path". Removing the space in the foldername "fixed" the issue.
I know I'm late to the party but here is a really good tutorial on how to fix this issue. I used this to fix my project.
Close down Visual Studio If the solution you are trying to migrate is
open in Visual Studio, then changes may be lost. Visual Studio may
overwrite/ignore your changes in some cases and the NuGet extension
will also try to re-enable Package Restore when it sees some projects
in the solution are missing it.
If you are using TFS Remove the NuGet.exe and NuGet.targets files from
the solution's .nuget folder. Make sure the files themselves are also
removed from the solution workspace. Retain the NuGet.Config file to
continue to bypass adding packages to source control. Edit each
project file (e.g., .csproj, .vbproj) in the solution and remove any
references to the NuGet.targets file. Open the project file(s) in the
editor of your choice and remove the following settings:
true ... ...
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download
them. For more information, see
http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is
{0}.
If you are not
using TFS Remove the .nuget folder from your solution. Make sure the
folder itself is also removed from the solution workspace. Edit each
project file (e.g., .csproj, .vbproj) in the solution and remove any
references to the NuGet.targets file. Open the project file(s) in the
editor of your choice and remove the following settings:
true ... ...
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download
them. For more information, see
http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is
{0}.
Migration Script
Many users have requested a migration tool to disable the
MSBuild-based package restore and convert to Automatic Package
Restore. The NuGet team has decided not to provide a supported tool
for this because of the high probability of edge cases that would be
unhandled. However, Owen Johnson has authored a PowerShell script that
can work in many cases. It's available on GitHub and can be used at
your own risk. In other words, be sure to commit to source control
before running it, just in case it doesn't work in your scenario.
Nuget.target Fix
When i get the nuget.targets not found error i use the package manager to uninstall-package one of the packages in the project and then reinstall it using install-package. It seems like it regenerates the nugets.target file then.
Easiest solution when you get this error in order to restore the missing NuGet.targets in Visual Studio Solution Explorer is to:
Right click on the solution file
From the context menu click "Enable Nuget Package Restore..." option
this will download the missing files in the ".nuget" folder :)
The above assumes you already have Nuget installed - if not follow the accepted answer above!
UPDATE:
Please note for Visual Studio versions beyond 2013 the option is called "Restore NuGet Packages"

Resources