Paket


The paket.dependencies file

The paket.dependencies file is used to specify rules regarding your application's dependencies. It contains top level dependencies from all projects in the solution, while paket.references file specifies dependencies only for particular project.

To give you an overview, consider the following paket.dependencies file:

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
source https://nuget.org/api/v2

// NuGet packages
nuget NUnit ~> 2.6.3
nuget FAKE ~> 3.4
nuget DotNetZip >= 1.9
nuget SourceLink.Fake

// Files from GitHub repositories
github forki/FsUnit FsUnit.fs

// Gist files
gist Thorium/1972349 timestamp.fs

// HTTP resources
http http://www.fssnip.net/1n decrypt.fs

The file specifies that Paket's NuGet dependencies should be downloaded from nuget.org and that we need:

Paket uses this definition to compute a concrete dependency resolution, which also includes transitive dependencies. The resulting dependency graph is then persisted to the paket.lock file.

Only direct dependencies should be listed and you can use the paket simplify command to remove transitive dependencies.

Sources

Paket supports the following source types:

Global options

Required Paket version

It is possible to require a specific Paket version for a paket.dependencies file. This can be achieved by a line which starts with version followed by a requested paket.exe version and optionally bootstrapper command line arguments:

1: 
2: 
3: 
4: 
5: 
version 3.24.1

source https://api.nuget.org/v3/index.json
nuget FAKE
nuget FSharp.Core ~> 4

or

1: 
2: 
3: 
4: 
5: 
version 3.24.1 --prefer-nuget

source https://api.nuget.org/v3/index.json
nuget FAKE
nuget FSharp.Core ~> 4

Strict references

Paket usually references all direct and transitive dependencies that are listed in your paket.references files to your project file. In strict mode it will only reference direct dependencies.

1: 
2: 
3: 
4: 
5: 
references: strict
source https://nuget.org/api/v2

nuget Newtonsoft.Json ~> 6.0
nuget UnionArgParser ~> 0.7

Framework restrictions

Sometimes you don't want to generate dependencies for older framework versions. You can control this in the paket.dependencies file:

1: 
2: 
3: 
4: 
framework: net35, net40
source https://nuget.org/api/v2

nuget Example >= 2.0 // only .NET 3.5 and .NET 4.0

Automatic framework detection

Paket can detect the target frameworks from your project and then limit the installation to these target frameworks. You can control this in the paket.dependencies file:

1: 
2: 
3: 
4: 
framework: auto-detect
source https://nuget.org/api/v2

nuget Example >= 2.0 // only the target frameworks that are used in projects

If you change the target frameworks in the projects then you need to run paket install again.

No content option

This option disables the installation of any content files:

1: 
2: 
3: 
4: 
5: 
content: none
source https://nuget.org/api/v2

nuget jQuery >= 0 // we don't install jQuery content files
nuget UnionArgParser ~> 0.7

CopyToOutputDirectory settings

It's possible to influence the CopyToOutputDirectory property for all content references in a group:

1: 
2: 
3: 
4: 
5: 
6: 
source https://nuget.org/api/v2
copy_content_to_output_dir: always

nuget jQuery 
nuget Fody
nuget ServiceStack.Swagger

It is also possible to define this behavior on level of individual NuGet packages:

1: 
2: 
3: 
4: 
5: 
source https://nuget.org/api/v2

nuget jQuery 
nuget Fody copy_content_to_output_dir: always
nuget ServiceStack.Swagger

import_targets settings

If you don't want to import .targets and .props files you can disable it via the import_targets switch:

1: 
2: 
3: 
4: 
5: 
import_targets: false
source https://nuget.org/api/v2

nuget Microsoft.Bcl.Build // we don't import .targets and .props
nuget UnionArgParser ~> 0.7

copy_local settings

It's possible to influence the Private property for references via the copy_local switch:

1: 
2: 
3: 
4: 
copy_local: false
source https://nuget.org/api/v2

nuget Newtonsoft.Json

Redirects option

This option tells paket to create Assembly Binding Redirects for all referenced libraries. This option only instructs Paket to create and manage binding redirects in existing App.config files, it will not create a new App.config file for you. However you can create App.config files by adding the --createnewbindingfiles flag to paket install

1: 
2: 
3: 
4: 
redirects: on
source https://nuget.org/api/v2

nuget UnionArgParser ~> 0.7

On the other hand, you can instruct Paket to create no Assembly Binding Redirects, regardless a package instructs otherwise.

1: 
2: 
3: 
4: 
5: 
redirects: off
source https://nuget.org/api/v2

nuget UnionArgParser ~> 0.7 redirects: on
nuget FSharp.Core redirects: force

If you're using multiple groups, you must set redirects: off for each one of them.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
redirects: off
source https://nuget.org/api/v2

nuget UnionArgParser ~> 0.7 redirects: on
nuget FSharp.Core redirects: force

group Build
    redirects: off
    source https://nuget.org/api/v2

    nuget FAKE redirects: on

Strategy option

This option tells Paket what resolver strategy it should use for transitive dependencies.

NuGet's dependency syntax led to a lot of incompatible packages on nuget.org. To make your transition to Paket easier and to allow package authors to correct their version constraints you can have Paket behave like NuGet when resolving transitive dependencies (i.e. defaulting to lowest matching versions).

The strategy can be either min or max with max being the default.

1: 
2: 
3: 
4: 
strategy: min
source https://nuget.org/api/v2

nuget UnionArgParser ~> 0.7

A min strategy means you get the lowest matching version of your transitive dependencies (i.e. NuGet-style). In contrast, a max strategy will get you the highest matching version.

Note, however, that all direct dependencies will still get their latest matching versions, no matter the value of the strategy option. If you want to influence the resolution of direct dependencies then read about the lowest_matching option.

The only exception is when you are updating a single package and one of your direct dependencies is a transitive dependency for that specific package. In this case, only the updating package will get its latest matching version and the dependency is treated as transitive.

To override a strategy for a single NuGet package, you can use the package specific strategy modifiers.

Lowest_matching option

This option tells Paket what resolver strategy it should use for direct dependencies.

The lowest_matching option can be either true or false with false being the default.

1: 
2: 
3: 
4: 
lowest_matching: true
source https://nuget.org/api/v2

nuget UnionArgParser ~> 0.7

A lowest_matching: true setting means you get the lowest matching version of your direct dependencies. In contrast, a lowest_matching:false will get you the highest matching version.

Note, however, that all transitive dependencies will still get their latest matching versions, no matter the value of the lowest_matching option. If you want to influence the resolution of transitive dependencies then read about the strategy option.

To override a lowest_matching option for a single NuGet package, you can use the package specific lowest_matching option.

Generate load scripts

This option tells Paket to generate include scripts which reference installed packages during package installation.

The generate_load_scripts option can be either true or false with false being the default.

1: 
2: 
3: 
4: 
generate_load_scripts: true
source https://nuget.org/api/v2

nuget Suave

Generated include scripts can be loaded like this:

1: 
#load @"paket-files/include-scripts/net45/include.suave.fsx"

Comments

All lines starting with with // or # are considered comments.

Fork me on GitHub