How do I reference an existing NuGet package from a new project?

How do I reference an existing NuGet package from a new project?

Well it’s actually all there, built into NuGet/Visual Studio.

  1. Select the solution in solution explorer.
  2. Right mouse click and select Manage NuGet Packages for solution…
  3. Select Installed packages.
  4. Locate the package that’s already installed.
  5. Click the Manager button.

How do I add a package to VS code?

Open your project workspace in VSCode. Open the Command Palette (Ctrl+Shift+P) Select > Nuget Package Manager GUI. Click Install New Package.

How do I create a NuGet package in Visual Studio 2019?

You can configure Visual Studio to automatically generate the NuGet package when you build the project.

  1. In Solution Explorer, right-click the project and choose Properties.
  2. In the Package tab, select Generate NuGet package on build.

How do I install NuGet packages from one project to another?

Simply copy existing packages. config file to your new project. Include this file into the project. Then follow to Package Manager Console and execute Update-Package -reinstall command.

Where are references stored Visual Studio?

By default, Visual Studio references assemblies stored in the GAC (Global Assembly Cache) with their specific version number.

Is there a solution containing projects exposed as NuGet?

If I got this right, as soon as you replace the nuget reference from B to A by a project reference, there is no project left which consumes A as a nuget package, right? So if there is no consumer any more, it is pretty obvious that the nuget package is superfluous.

How to pack a referenced project into a NuGet?

The only supported way to pack projects that use PackageReference, or any SDK style project, is to use NuGet’s MSBuild pack target (either dotnet pack or msbuild -t:pack ). However, this does not have an equivalent to nuget.exe’s IncludeReferencedProjects.

When does the NuGet package become superfluous?

So if there is no consumer any more, it is pretty obvious that the nuget package is superfluous. Let me scetch one additional scenario here: what if there will be another external project C in the future which wants to consume A by a nuget package – should B then be changed to consume A as a nuget package as well?

How to change project reference to package reference?

If you have a ProjectReference, it will override any package references to the same package ID in the restore graph. I tried this myself (added both the ProjectReference and the PackageReference in the csproj file).