Adding NuGet Packages with Visual Studio Code
Create a new Project
File -> New Project is not an option here, so in order to creare a console app we need to do teh following:
File -> Open Folder and open or create a new folder where your new project will be. Then open Terminal via Terminal -> New Terminal and run the following commant to create a console app:
1 |
dotnet new console |
Add NuGet Packages
You can run the following commands from the Terminal
1 2 |
dotnet add package Newtonsoft.Json dotnet restore |
In most cases it works. I came across the problem when trying to add Newtonsoft.Json gave me a 401 error in the Terminal logs. Now what?
Install NuGet Package Manager to Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=jmrog.vscode-nuget-package-manager
Now in order to add packages you need to go View -> Command Palette or press Crt + Shift + P and type “>nuget” there


Select Add Package and then you can type the name of the package you are looking for. It worked better for me and I installed Newtonsoft.Json OK.