Lesson 26. Working with NuGet packages
In the preceding lesson, you spent time working with non-F# projects from F#, as well as learning a few tricks on working with scripts. In this lesson, you’ll move on to working with dependencies within scripts and projects, rather than writing standalone scripts. You’ll see
- How to work with NuGet packages in F#
- Tips and tricks when working with scripts
- What the Paket dependency manager is
The good news is that NuGet packages work out of the box with F# projects in Visual Studio. There’s no difference compared to working with C#!
Let’s first see how NuGet packages work with F#.
Now you try
You’re going to download a NuGet package from the main public NuGet server and use it within an F# class library:
1. Create a new F# class library in Visual Studio called NugetFSharp.
2. Using the standard Manage NuGet Packages dialog box, add the Newtonsoft .Json package to the project.
3. You’ll see that the package is downloaded and added as a reference, as in your C# project. You can now use it directly from your F# source files.
4. Change the contents of the Library1.fs file to the following code.