How do I add a NuGet package to the Server?
You can add NuGet packages to the server to give it more capabilities. You can download a wide variety of packages from the official NuGet site.
In this example we will add the FsToolkit ErrorHandling package package.
I'm using the standard template (Paket)
1. Add the package
Navigate to the root directory of your solution and run:
dotnet paket add FsToolkit.ErrorHandling -p Server
This will add an entry to both the solution paket.dependencies file and the Server project's paket.reference file, as well as update the lock file with the updated dependency graph.
Find information on how you can convert your project from NuGet to Paket here.
For a detailed explanation of package management using Paket, visit the official docs.
I'm using the minimal template (NuGet)
1. Navigate to the Server project directory
2. Add the package
Run the following command:
dotnet add package FsToolkit.ErrorHandling
Once you have done this, you will find an element in your fsproj file which looks like this:
<ItemGroup>
<PackageReference Include="FsToolkit.ErrorHandling" Version="1.4.3" />
</ItemGroup>
You can also achieve the same thing using the Visual Studio Package Manager, the VS Mac Package Manager or the Package Manager Console.
For a detailed explanation of package management using NuGet, visit the official docs.