I have a strange issue:
While i'm coding, my Visual Studio randomly -out of nowhere- says it cannot find the previously installed Nuget Packages. Then it marks half of my code with errors as the packets for the usings are missings.
I then have to download them again and the issue is instantly fixed. These package deletions happen completely out of the blue and since a week over and over again. I cannot track down the issue why it deletes these packages in the first place (?) (or is unable (?) to find downloaded Packages).
Is there a known fix to this?
These package deletions happen completely out of the blue and since a
week over and over again. I cannot track down the issue why it deletes
these packages in the first place
I wonder if you download the project from any code hosting platforms like TFS before you encouter this issue. And from your description, the nuget references are missing which is not a normal behavior. Also, I want to know exactly what you did to cause this issue.
To troubleshoot your issue, you can try these steps:
1) close the VS Instance, delete NuGet.Config file under C:\Users\xxx(User Name)\AppData\Roaming\NuGet\NuGet.Config, restart VS and then restore nuget packages.
2) Besides, every time you encouter this issue, Right-click on the Solution-->Restore Nuget Packages and this will restore any nuget missing nuget packages.
In addition, please make sure these two options are checked by Tools-->Options-->Nuget Package Manager-->General-->Nuget Restore. And the missing packages will be restored automatically when you execute Build.
Hope this could help you.
Related
I just installed a package through NuGet, but it shows a yellow exclamation mark icon in my Solution Explorer, see screenshot below.
Why does this happen, and how can I resolve it?
Many times it is just that Visual Studio is out of sync. Closing the solution and re-opening will magically fix these errors in many cases. It's easy enough that it should be one of the first things you try.
In my case I had to manually update targetFramework in packages.config where "problematic" nuget was referenced.
My steps:
I checked the path where NuGet is installed
I searched config where the NuGet is referenced within the solution
I manually changed targetFramework according the last segment/directory of NuGet's installation path
I know this is an old thread, but still, it happens even with VS 2022, when you move the project to a different physical location even with the same name.
In many cases, absolutely all the dependencies are suddenly marked with a yellow or brown exclamation mark triangle.
One solution is to remove one dependency and reload it via NuGet. Updating a dependency if possible does the same, and in both cases, apparently forces VS to get the right location of the dependencies.
Sometimes this can happen somewhat persistently after changing the TargetFramework(s) on a project that has already been loaded into Visual Studio. In my experience, the easiest way to ensure things are working correctly after changing the TFMs on a project is to close the solution, manually remove all the relevant bin/obj directories as well as the .vs folder next to the solution file.
For me i had this while using flaui dependency which was not matching the TargetFramework after changing from net6.0 to net6.0-windows it worked.
csproj file
I have a large solution with about 30 subprojects. Each subproject depends on a nuget package which gets updated regularly. So I end up typing for example
Update-Package AcmeWunderLib
every few days. The problem is this process takes about 10 minutes to run with the result being a very small change in each package.config and $name$.csproj file. Is it possible to do this operation in parallel for some performance improvement or will any attempt cause Nuget to corrupt itself?
The package update time is consist of downloading package and uninstalling/installing package. The downloading action will execute only once when first time download it, so the uninstalling/installing action will occupy almost all update time.
According to your log, NuGet takes under a second to gather dependency info, but take too long time to uninstall/install package. It`s only takes 2-5 second to update a package for one project in my test. So please check your machine performance at first when you encounter this issue.
For this issue, I would like provide you some troubleshootings:
Update your NuGet, NuGet team have more improvements in the pipe for 3.5rc and 3.4.5.
Clean the old version packages in your package feed and NuGet cache.
Disable other NuGet repositories except nuget.org, perhaps one of them is timing out.
Test this issue on other workstations or build servers, and you can create some projects in a new solution to verify this issue.
Hope that can help you.
Here is the real solution.
DONT RUN UPDATE-PACKAGE FROM WITHIN VISUAL STUDIO
Close visual studio
Open up powershell from the desktop or start menu
Make sure nuget is on your path
Run the following command substituting devdept.eyeshot for your package and WeinCAd.Net.sln for your solution file.
nuget update -Verbosity detailed -Id devdept.eyeshot .\WeinCad.Net.sln
The whole process lasted less than 10 seconds.
EDIT
I have been warned that this does not do all the same things that running nuget update from within Visual Studio does. All the above does is change the base path for the DLLs. It can't add and remove references. However this is enough for my use case.
Our VS2013 solutions contain a solution folder called .nuget, containing the files NuGet.config, NuGet.exe, NuGet.targets. What is the significance of this folder and what uses the files? Is it related to the "enable package restore" feature?
If I install or update a package (via the "Manage NuGet Packages" UI or package manager console), does this involve running the above NuGet.exe, or something else? VS is telling me that the NuGet Package Manager is up to date (via the Extensions and Updates dialog), however the above NuGet.exe is quite old. I've also found a very old NuGet.exe file in C:\Program Files (x86)\NuGet\. What uses the latter, and what are the implications of these exes being out of date?
The reason I ask is that we've been having problems with a couple of solutions over recent weeks. We can't update NuGet packages - the operation fails with the message "Error: An item with the same key has already been added". I'm trying to track down the cause, and wondering if these out of date NuGet.exe files might have something to do with it.
As far as I remember this folder is useless now with the latest nuget extension to Visual Studio. It was used before and was nothing but pain in the ass. I am not 100% sure about 2013, but in 2015 all works fine without it, so my suggestion is to update to the latest available nuget extension version and try to delete the folder, most likely everything will work.
Now packages go to current user folder, and use the config from %AppData%\NuGet\NuGet.config. For NuGet 2.6 or earlier, this setting was available in a project-specific .nuget\nuget.config file.
You can read more about it here.
So nuget is gradually getting better and easy to use without too much thinking of all this "magic" folders and stuff.
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.
I am getting an error when trying to enable package restore in a new solution I just created. The error in VS2012 is:
NuGet Package Manager
An error occurred while configuring the solution to restore NuGet
packages on build
Unable to read package from path 'NuGet.Build.2.7.0.npkg'.
I tried opening the solution in VS2010 to work around the problem and I am also getting an error when trying to enable package restore, but the message is different:
NuGet Package Manager
An error occurred while configuring the solution to restore NuGet
packages on build
Archive file cannot be size 0.
I tried creating a new solution, but got the same result.
I then tried doing a repair on VS2012 update 3 and rebooting. Still getting the problem.
I also scanned the folder, project, and solution file for anything NuGet or .nupkg, but there is nothing there.
So how can I get this feature working again? The last time I used it was about a week ago, and I don't remember specifically what I changed since then. I uninstalled the VS Power Tools package that I installed about a week ago, but that didn't fix the problem either.
Update
I followed the "removal" instructions here and used a project I already have as a template to enable package restore manually. However, I am still looking for a better solution because this is a feature I use frequently.
I also tried uninstalling and reinstalling NuGet from visual studio, but I still get the same issue. If memory serves correctly, there was a recent NuGet update (is there a log for VS extension installation so I can check?).
I suspect that the NuGet.Build.2.7.0.npkg file is zero bytes due to a failed download. NuGet.Build.2.7.0.npkg is the NuGet package that Visual Studio downloads in order to enable package restore for your solution.
Take a look in your cache and see if this file is zero bytes. If so then delete the file or clearing the cache and try enabling package restore again. The cache is under your profile in a directory similar to:
C:\Users\YourUsername\AppData\Local\NuGet\Cache
You can also browse to the cache from inside Visual Studio by opening the Package Manager Settings, selecting General and clicking the Browse button.
All of the previous answers, plus this one: can you run .\nuget\nuget.exe update -self if this is a solution in which package restore was previously enabled?
check whether your nuget package manager is updated one or not.
Check this from Tools-> Extensions and Updates -> Updates
Update your Nuget Package Manager and then it will work