F# Interactive Integration
F# Interactive v5 and above ships with extensions mechanism.
FSharp.DependencyManager.Paket implements this extension mechanism to hook same power as paket.dependencies file right inside .fsx scripts.
Making sure Paket is found
The extension runs the Paket .NET tool. It looks for, in order:
-
Paket installed with
dotnet tool install paket --tool-path, in the folder hierarchy containing the script, directly or in a.paketfolder, -
the local tool of the first
.config/dotnet-tools.jsonup from the script that has Paket (rundotnet tool restorefirst), - a global tool, in
~/.dotnet/toolsor~/.paket, -
the most recent Paket .NET tool restored in the NuGet packages folder
(
~/.nuget/packages/paket).
Install the extension
You have two choices to deploy the assembly:
Copying the assembly next to the host process
Install the FSharp.DependencyManager.Paket.dll aside of your F# Interactive binaries or the binary of the host process loading the extensions.
In general, the process will explicitly list the folders it is currently checking for extensions:
|
The locations to copy FSharp.DependencyManager.Paket.dll
Dotnet SDK:
- Windows
C:\Program Files\dotnet\sdk\<version number>\FSharp
- macOS
/usr/local/share/dotnet/sdk/<version number>/FSharp
- Linux
/home/user/dotnet/sdk/<version number>/FSharp
Visual Studio:
- For Editor Support
C:\Program Files\Microsoft Visual Studio\<version number>\Community\Common7\IDE\CommonExtensions\Microsoft\FSharp
- For Fsi Window Support
C:\Program Files\Microsoft Visual Studio\<version number>\Community\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools
Passing the folder of the extension as --compilertool flag
Use the --compilertool flag when invoking F# Interactive or refer to the documentation of the host process.
For example on windows:
|
For example on unix:
|
Usage in scripts
Using it involves the #r directive with paket extension.
Here is an example importing FSharp.Data library:
#r "paket: nuget FSharp.Data"
open FSharp.Data
// do cool stuff
It is also possible to use github dependencies to import individual files:
#r "paket: github fsharp/FAKE src/legacy/FakeLib/Globbing/Globbing.fs"
#load @"fsharp\FAKE\src\legacy\FakeLib\Globbing\Globbing.fs"
let f = Fake.Globbing.search
Usage in FSharp.Compiler.Service
Same remarks as for installation section above, you'd either make sure the assembly is deployed aside the host process binary, or you'd pass --compilertool flag when building the project options (through GetProjectOptionsFromScript).
namespace FSharp
--------------------
namespace Microsoft.FSharp
Paket