Scott Hanselman

Visual Studio 2017 can automatically recommend NuGet packages for unknown types

March 24, 2017 Comment on this post [9] Posted in VS2017
Sponsored By

There's a great feature in Visual Studio 2015.3 and Visual Studio 2017 that is turned off by default. It does use about ~10 megs of memory but it makes me so happy that I turn it on.

It's under C# | Advanced in Tools Options. Or you can just type "Advanced" in the Quick Launch Bar (via Ctrl+Q if you like) to jump there.

I turn on "Suggest usings for types in NuGet packages" and "Suggest usings for types in reference assemblies."

I turn on "Suggest usings for types in NuGet packages" and "Suggest usings for types in reference assemblies."

For example, if I am typing some code and start referencing a Type that isn't in my project but could be...you know how sometimes you just need a using statement to bring in a namespace? In this Web App, I already have Json.NET so it recommends a using statement to bring it into scope.

Can't find JSON

But in this Console App, I have no packages beyond the defaults. When I start using a type like JObject from a popular NuGet, Visual Studio can offer to install Json.NET for me!

Find and install latest version

Or another example:

XmlDocument

And then I can immediately continue typing with intellisense. If I know what I'm doing, I can bring in something like this without ever using the mouse or leaving the line.

JObject is now usable

Good stuff! 


Sponsor: Check out JetBrains Rider: a new cross-platform .NET IDE. Edit, refactor, test, build and debug ASP.NET, .NET Framework, .NET Core, or Unity applications. Learn more and get access to early builds!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
March 24, 2017 15:20
This is one of my favorites in VS2017. But I've been enjoying 'move type to matching file' the most and 'go to all' almost as much.
March 24, 2017 16:56
it's really helpful in .xml.
March 25, 2017 0:48
This is great; time I installed VS2017. Judging from this and Daniel Crabtree's comment, it looks like vanilla VS is catching up with Resharper which is good because it means JetBrains will keep adding more cool stuff (I hope, having just renewed my license).
March 25, 2017 23:09
Doesn't VS2015 do the same?
March 27, 2017 15:16
Also under 'Basic | Advanced' in 'Tools | Options' ;)
AT
March 30, 2017 18:49
I would love to see this feature on by default. It also assists when people want to use the new ValueTuples for the first time in a project too.
March 30, 2017 22:03
Nuget consolidate would probably have saved me a man-year of dll hell. Thank god it's here!
April 05, 2017 16:20
Scott,

Thanks for the tip. Initially I was disappointed that the same functionality wasn't avaiable in VS2017! I would be nice to have this info in the release notes.
April 06, 2017 15:17
How is it decided whats popular and whats shown and whats isn't? Or is this based on you local package cache? It would be great if it shows suggestions from internal feeds as well.

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.