The project references NuGet packages that are not on this computer - c#

i'm getting following error when i build my solution in visual studio 2015.
but when i try to add that particular package then visual studio show it already added

Did you notice something? the version is different you need version 1.0.5 instead of 1.0.7

Open Nuget Package Manager and pick "Unistall" on this package, than istall it again. If this does not help you do next:
Unload project and remove all reference on this package from .csproj file
Remove reference on this package from Web.config (or App.config) if it there.
Remove reference from packages.config file
Install via nuget you package again.
Hope this helps you.

Right click solution in visual studio and select "Restore Nuget Packages", it will download the missing packages

Use the following command in the Package Manage Console:
Update-Package -reinstall -Project YourProjectName
It is by project, but this way is garanteed it works, at least in 100% of cases that happen to me.

Related

How to resolve "NuGet package restore failed" in Visual Studio?

I got an error
NuGet package restore failed. Please see Error List window for detailed warnings and errors.
while building my solution. Package manager can't restore my 2 projects:
Unable to find project information for 'C:\(...)\MultiLinker.Courier.Dext.Model.csproj'. The project file may be invalid or missing targets required for restore.
In tools I allow package manage to download packages:
Ran into the same issue. In my case, it was because Visual Studio only had the Offline Package source and could not resolve the packages I needed. I added in the nuget.org source as shown below in the NuGet Package Manager settings and right clicked on the solution and selected restore packages. and it resolved the issue.
open Nuget Package Manager -> Package Source > Add https://nuget.org/api/v2
I might be forgetting some steps, but a crucial step for me to fix this was running nuget restore from the commandline (Trying to restore from Visual Studio UI was not sufficient for some reason).
I also added a plugins folder given to me by a teammate to my .nuget folder that supposedly makes it handle our credentials automatically, so if you are having this issue maybe that is something you are missing as well.
In my case it was my Company DevOps credentials being out of date
Account Settings > Change credentials in the dialog that opens
On Visual Studio Code (VSCode) this can be solved this way:
dotnet new nugetconfig
thank you it works fine
and solved all issues of nuget
by creating the new value in the setting of nuget
under tools > nuget package manger > package manger settings
nuget package sources
add new value nuget.org and https://www.nuget.org/api/v2/
then save and update you project
it will work
The nuget restore did not work for me but once I used nuget.org it worked just fine. This was the best solution for me.
Upgrading my out of date Visual Studio helped for me:
Help Menu: Check for Updates...

using Newtonsoft.Json in c# not working even after downloading package

I downloaded Newtonsoft.Json.11.0.2 package by package manager console,
and it certainly showed that the package is installed in project.
However, when I try to use the package
using Newtonsoft.Json
visual studio keeps warning me the name is not found and draws red underline.
What should I do? uninstalling and reinstalling the package didn't work.
Make sure you have selected same project while installing package
Add a reference by clicking on your project in the solution explorer with right click -> References -> Newtonsoft Json.
Add it and compile.
Had the same issue, i notice that i have some bll files that have been installed
Microsoft.AspNetCore.Mvc.NewtonsoftJson
Newtonsoft.Json
Newtonsoft.Json.b..
i removed all the files exept 'Newtonsoft.Json' closed the vs.code reopened it and it worked!

Visual Studio: how to add nuget packages as references when doing "Restore NuGet packages"

I have downloaded all the packages using "Restore NuGet packages" that existed in packages.config
However, they do not appear in the References, so VS is not aware of them.
Is there a way to add them automatically to the reference list? Possibly in 1 step?
The references are tracked as part of the project files and are usually added as part of a NuGet package's initial installation. Restoring the packages will just download them.
This means it sounds like you need to reinstall those specific packages whose references are missing.
To do this, run the Update-Package command in the Package Manager Console with the -reinstall flag on it.
Update-Package <package_name> -ProjectName MyProject -reinstall
Optionally, you can add the -Version flag if you need to stick with a version that's not the latest, just make this version number match that stored in your packages.config file.
Or alternatively, to reinstall all packages for a given project:
Update-Package -Reinstall -ProjectName <project_name>
I too have VS 2017. However, I haven't encountered any problem with Nuget packages.
Anyway, try this: Right-click the References folder in the project, then click "Manage Nuget Packages" then click "Restore".
If that doesn't work, close VS, delete all files in bin, obj and packages folders and then repeat the steps above.
Also make sure the items "Allow NuGet to download missing packages" and "Automatically check for missing packages during build..." are checkekd in Tools/Options/Nuget Package Manager setting as follows:

'Newtonsoft' could not be found

I pasted the code from http://www.codeproject.com/Tips/789481/Bridging-the-Gap-between-Linqpad-and-Visual-Studio into Visual Studio 15. It tells me that 'Newtonsoft' could not be found. I open the folder "\Microsoft Visual Studio 14.0\Common7\IDE\PrivateAssemblies" and found that the file Newtonsolft.Json.dll is already there. Could anyone tell me how to fixed problem?
Solution Explorer->Right Click on Project Name -> Click on Manage Nuget Packages -> Search for newtonsoft -> Click on install button
Go to Tools -> Library Package Manager -> Package Manager Console
and in the console just write Install-Package Newtonsoft.Json -Version 9.0.1
For me I had the package already installed but it was missing the references and it could not be added.
Helped me: in NuGet Package Manager to downgrade and upgrade Newtonsoft.Json
You have to get the correct NuGet package. From your link:
You can open the NuGet package manager in: Tools -> Nuget Packet Manager -> Manage Nuget Packages for Solution..
I had a similar problem and Google API's had a dependency on Newtonsoft.Json, not allowing me to uninstall Newtonsoft.Json and trying to reinstall.
Removing and and reinstalling Newtonsoft.Json will likely solve the problem, but in my situation, I had to go into Nuget Package Manager -> find Newtonsoft.Json -> select Options dropdown -> check "Force uninstall even if there are dependencies on it".
Checking that box allowed me to remove and subsequently reinstall Newtonsoft and the solution properly referenced it after.
I had the same problem with visual studio 2019. Simply restarting visual studio fixed the issue.
After restarting, the References list in Solution Explorer did show the "Newtonsoft.json".
Right click on the client project side and select Manage NuGet packages.
Then search for Newtonsoft.Json on browse and install.
If the class you are trying to use Newtonsoft is in client you must install the package for the client.

NuGet has problems with missing packages, how to restore?

When I try to compile my program I get the following error:
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=317567.
Now when I right click on the solution and press
All packages are already installed and there is nothing to restore.
I tried manually reinstalling every package which didn't solve the problem, I tried reinstalling NuGet but that didn't help either and I even tried reinstalling visual studio.
I also tried moving the package folder from the tfs folder to overwrite my package folder but that didn't solve anything. I also tried redownloading them with this package missing, that didn' t solve the problem either.
Anybody know how to restore the nuget packages?
Use Package Manager Console in Visual Studio to run this command.
1.This will restore all packages from solution
nuget restore YourSolution.sln
2.If you want to reinstall the packages to the same versions as were previously installed
Update-Package -reinstall
Honestly, whoever developed the NuGet command for VS needs to go back to the drawing board. They totaly missed the fact that sometimes these DLL(s) and/or files get corrupt or deleted. a "NuGet Get-Packages -Force" option would really save their bacon. The only GAP I see is that VS and the Package console does not allow you to invoke a forced download from NuGet. Even clearing the cache via VS is useless.
I ran into this issue when I tried to build my project on a computer where the packages-folder did not already exist in the solution root.
When the project file was initially created, it seems VS2019 added the following into the project file:
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
</Target>
From what I understand those settings are deprecated nowadays, no idea why VS inserted it in the first place.
Anyway, after removing those lines VS restored the packages and built the solution correctly again.
It's probably a good idea to clear the Nuget Cache by deleting the contents within this directory: C:\Users\{your_username}\AppData\Local\NuGet
All you need is that:
Open the Package Manager Console and run this command: Update-Package -reinstall
P.S: VS2017 and above NuGet Package Manager is included with Visual Studio, no need to install anything else.
The problem with the functionality of the NuGet package can also be caused by the fact that NuGet package is requiring certain dependency that the project does not meet.
NuGet package can have a declared dependency in Dependecies section, e.g. .NETFramework,Version=v.4.6.2 while the project is targeted to an older version (Target framework: .NET Framework 4.6.1.).
Instead of the NuGet system notifying the user of this fact, the project simply does not compile.
In my case, I have different Nuget configurations, and somehow the HintPath in the project file didn't fit.
Maybe you should check if the HintPath leads to the right NuGetPackages folder.
You should also check the following entries at the top of the file:
And at the bottom of the file:
All these paths should point to the right NuGetPackage folder in your file structure.
In my case the problem was solved by deleting the "obj" folder(s) and then rebuilding the solution.
The "obj" folder had several NuGet related files that still referred to version 0.0.2 of a package while all projects in the solution were already using version 1.0.0 of that package. Building the solution failed with the error message "package with version 0.0.2 could not be found". The solution with build folders included was recently copied from another machine.
Well it's probably a bad way but I found that it works if I just delete the line
http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
from the project.csproj , not sure if this is going to cause problems later on but it works for now.

Categories

Resources