Paket


paket simplify

Simplify declared dependencies by removing transitive dependencies.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
paket simplify [--help] [--interactive]

OPTIONS:

    --interactive, -i     confirm deletion of every transitive dependency
    --silent, -s          suppress console output
    --verbose, -v         print detailed information to the console
    --log-file <path>     print output to a file
    --from-bootstrapper   call coming from the '--run' feature of the bootstrapper
    --help                display this list of options.

If you add the --verbose flag Paket will run in verbose mode and show detailed information.

With --log-file [path] you can trace the logged information into a file.

A note on strict mode

paket simplify will also affect paket.references files, unless strict mode is used.

Important: paket simplify is a heuristic approach to dependency simplification. It often works very well, but there are rare cases where simplify can result in changes of the package resolution.

Interactive mode

Sometimes, you may still want to have control over some of the transitive dependencies. In this case you can use the --interactive flag, which will ask you to confirm before deleting a dependency from a file.

Notes and Warnings

It is possible through the use of paket simplify to make unintended changes to your paket.lock file if a transitive dependency is removed and a subsequent install is run. This can occur especially if the version specification that previously existed for the transitive dependency is different than the version specification that is automatically generated by Paket based on the primary dependencies of your project. An example may help illustrate the conditions where this could occur.

Imagine a paket.dependencies file with the following contents:

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

nuget Foo 1.0.0
nuget Bar 1.0.0

Let us imagine that package Bar has a dependency on package Foo for any version from 1.0 through 2.0. The paket.lock file that results for this combination is:

1: 
2: 
3: 
4: 
5: 
NUGET
  remote: https://nuget.org/api/v2
    Foo (1.0.0)
    Bar (1.0.0)
      Foo (<= 2.0.0)

In this situation, if paket simplify is run, the Foo dependency will be removed, resulting in a paket.dependencies of:

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

nuget Bar 1.0.0

like we expect. But now, if an install is run, the Foo dependency will be free to update to the maximum allowed by the Bar dependency, which could have unforseen consequences if the author of Foo has introduced a breaking change.

Example

When you install Castle.Windsor package in NuGet to a project, it will generate a following packages.config file in the project location:

1: 
2: 
3: 
4: 
5: 
<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Castle.Core" version="3.3.1" targetFramework="net451" />
  <package id="Castle.Windsor" version="3.3.0" targetFramework="net451" />
</packages>

After converting to Paket with paket convert-from-nuget, you should get a following paket.dependencies file:

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

nuget Castle.Core 3.3.1
nuget Castle.Windsor 3.3.0

The NuGet packages.config should be converted to following paket.references file:

1: 
2: 
Castle.Core
Castle.Windsor

As you have already probably guessed, the Castle.Windsor package happens to have a dependency on the Castle.Core package. Paket will by default (without strict mode) add references to all required dependencies of a package that you define for a specific project in paket.references file. In other words, you still get the same result if you remove Castle.Core from your paket.references file.

This is exactly what happens after executing paket simplify command. After running it, paket.dependencies will contain:

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

nuget Castle.Windsor 3.3.0

And paket.references file contains:

1: 
Castle.Windsor

Unless you are relying heavily on types from Castle.Core, you would not care about controlling the required version of Castle.Core package. Paket will do the job.

The simplify command will help you maintain your direct dependencies.

Fork me on GitHub