Why ReSharper doesn't add NuGet packages when it suggests to reference them?

Viewed 950

I'm working on a solution that has multiple C# projects. One of these projects already uses a NuGet package (e.g. Newtonsoft), correctly declared as such in the packages.config file and in its csproj file.

When working on a different project inside the same solution and making reference to a class/interface that is in the aforementioned NuGet package, ReSharper accurately suggests to add it as reference.

However, when accepting this suggestion, the end result is that the reference is only added to the csproj file and not to the packages.config file. It is important to mention that I'm not using the new csproj format which has PackageReferences and collapses all NuGet data into that single file.

In this article, you can see that this was actually a problem with ReSharper some time ago and it was solved with a plugin:

https://blog.jetbrains.com/dotnet/2012/11/20/add-packages-not-references-a-nuget-plugin-for-resharper/#comment-562837

However, since version 9.1 this was deprecated since it was supposedly included in the main ReSharper product:

https://github.com/JetBrains/resharper-nuget#deprecated

PD: I'm using VisualStudio 2017 and ReSharper 2017.2.2.

1 Answers

Just found that the reason is that since NuGet is unable to resolve some dependencies needed to install the referenced package, ReSharper opts to add the entry only to the csproj file, leaving the packages.config untouched. This should definitely be an error or warning so I reported it to JetBrains: https://youtrack.jetbrains.net/issue/RSRP-475208

Related