Packaging your libraries for NuGet distribution
Before we learn how to create and package our own libraries, we will review how a project can use an existing package.
Referencing a NuGet package
Let's say that you want to add a package created by a third-party developer, for example,
- In the
AssembliesAndNamespacesproject, add a reference to the
Newtonsoft.JsonNuGet package, either using the GUI for Visual Studio 2022 or the
dotnet add packagecommand for Visual Studio Code.
- Open the
AssembliesAndNamespaces.csprojfile and note that a package reference has been added, as shown in the following markup:
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
If you have a more recent version of the
Newtonsoft.Json package, then it has been updated since this chapter was written.