Nikolai Samteladze Nikolai Samteladze - 2 months ago 37
C# Question

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

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

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

Comments