Automatically add NuGet dependencies and using statements in Visual Studio Code?

Nikolai Samteladze picture Nikolai Samteladze · Dec 25, 2015 · Viewed 13.3k times · Source

I am using Visual Studio Code to develop an ASP.NET 5 application on Mac. In order to use new classes (framework or third-party) in my .cs file, I need to

  1. Manually add a NuGet dependency in project.json and then
  2. Manually add a using statement to my .cs file.

It seems that there should be a better way to import new functionality that doesn't involve searching for the right NuGet and the correct namespace. Any suggestions?

Answer

Nikolai Samteladze picture Nikolai Samteladze · Dec 27, 2015

Well, once I got my IntelliSense issues figured out (Visual Studio Code on Mac), I don't have to type using statements anymore. OmniSharp-based IntelliSense is smart enough to suggest (Cmd + . on Mac) adding them for me:

enter image description here

I still have to add a NuGet dependency manually, but I think this is the default behavior in the full Visual Studio too and you need ReSharper to get smarter than that.

enter image description here