How can I install a Nuget Package in Visual Studio Code? I know in Visual Studio, we can do this through the Nuget Package Manager console, but how do I do it in VS Code?
-
i would prefer console because the extension has no good reviewsGyan Parkash– Gyan Parkash2016-11-19 08:43:43 +00:00Commented Nov 19, 2016 at 8:43
-
The way i do it, is to use nuget.org, search, and just use the PackageReference (located with the other installment options). Works pretty good, and you get a good UI for the nuget it self.mslot– mslot2020-04-16 17:53:56 +00:00Commented Apr 16, 2020 at 17:53
-
1Doesn't look like any of these steps/processes work any longer. I tried this on the latest 2024 installation of VSCode. It does not respond to the stated Nuget Package Manager: Add Package command. It does nothing. Has this process changed since 2017? If so, what is the latest method of getting any package (in my case I need Lazarus IDE pascal crap) installed into VSCode. I cannot download the IDE directly (company restrictions), so I have to use this nuget package gemors to try get Lazarus installed...Hendrik Potgieter– Hendrik Potgieter2024-08-01 07:54:35 +00:00Commented Aug 1, 2024 at 7:54
14 Answers
From the command line or the terminal windows in VS Code editor:
dotnet add <PROJECT> package <PACKAGE_NAME> [options]
Ex.:
dotnet add MyApp package MySql.Data -Version 8.0.31
See this article by Scott Hanselman
4 Comments
--version or -v ( not -Version); (2) I had to include the .csproj file extension. Full example that worked for me: dotnet add MyApp.csproj package MySql.Data --version 8.0.31Edit: From the comments below:
22 June 2019: "This extension is now unpublished from Marketplace. You can choose to uninstall it." 2¢. – ruffin Jun 22 '19 at 13:23
The provided link above points to ".Net Core Project Manager (Nuget)" - try: https://marketplace.visualstudio.com/items?itemName=jmrog.vscode-nuget-package-manager – samis Oct 3 '19 at 16:14
You can use the NuGet Package Manager extension.
After you've installed it, to add a package, press Ctrl+Shift+P, and type >nuget and press Enter:
Type a part of your package's name as search string:
Choose the package:
And finally the package version (you probably want the newest one):
4 Comments
Nuget Gallery provides a GUI similar to the full Visual Studio. See below.
How To Use:
- Install
Nuget Galleryfrom extension marketplace. - Launch from the menu bar
View > Command Paletteor ⇧⌘P (Ctrl+Shift+P on Windows and Linux). TypeNuget: Open Gallery. - The GUI above is displayed. You can filter just like in regular Visual Studio.
- Make sure the
.csproj filecheckbox is selected, select version from dropdown, and click install button.
UPDATE
Earlier versions, as noted in the comments, had an issue where the .csproj checkbox was not visible when a package in the csproj file was missing a version number like below.
<PackageReference Include="Microsoft.AspNetCore.App" />
This has been fixed in newer versions of the extension so if you have an older version with this issue, please update it to the latest version.
6 Comments
.csproj file tick option in the current version. Maybe that's what my problem is. github.com/pcislo/vscode-nuget-gallery/issues/15.csproj not having version numbers. See issue comment. I've updated my answer to include that.Open extensions menu (Ctrl+Shift+X), and search ".NuGet Package Manager".
3 Comments
Example for .csproj file
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="7.0.7-m61" />
</ItemGroup>
Just get package name and version number from NuGet and add to .csproj then save. You will be prompted to run restore that will import new packages.
5 Comments
dotnet and VSCode then why would you even need those project files.nuget package manager gui extension is a GUI tool that lets you easily update/remove/install packages from Nuget server for .NET Core/.Net 5 projects
> To install new package:
- Open your project workspace in VSCode
- Open the Command Palette (Ctrl+Shift+P)
- Select > Nuget Package Manager GUI
- Click Install New Package
For update/remove the packages click Update/Remove Packages
1 Comment
- Install NuGet Package Manager
Ctrl+Shift+Pon Windows orCommand+Shift+Pon Mac- Search for NuGet Package Manager: Add Package
- Enter package name i.e. AutoMapper
- Select package & version
- Restore if needed
Comments
The answers above are good, but insufficient if you have more than 1 project (.csproj) in the same folder.
First, you easily add the "PackageReference" tag to the .csproj file (either manually, by using the nuget package manager or by using the dotnet add package command).
But then, you need to run the "restore" command manually so you can tell it which project you are trying to restore (if I just clicked the restore button that popped up, nothing happened). You can do that by running:
dotnet restore Project-File-Name.csproj
And that installs the package
Comments
You can use .NET Add Command
Usage: dotnet add [PROJECT] [command] [options]
Arguments: PROJECT: The project file to operate on. If a file is not specified, the command will search the current directory for one.
Options: -?, -h, --help Show command line help.
Commands:
package <PACKAGE_NAME> Add a NuGet package reference to the project.
reference <PROJECT_PATH> Add a project-to-project reference to the project.
1 Comment
Just take a break and restart. Save all the necessary changes after the compare, it worked for me after restart. Thanks






