Paket


Getting Started with Paket

This guide will show you

The following guide is assuming you are using the paket.exe command line tool. For information on installing the command line tool follow the instructions for your operating system for installation. There are editor plugins for Visual Studio, Atom and other which can make this process easier and provide additional tooling like syntax highlighting. Check our editor support page to see if your editor has a Paket plugin. If you are starting a new solution from scratch then take a look at ProjectScaffold. This project helps you get started with a new .NET/Mono project solution with everything needed for successful organising of code, tools and publishing and includes Paket.

Manual setup

Downloading Paket's Bootstrapper

  1. Create a .paket directory in the root of your solution.
  2. Download the latest paket.bootstrapper.exe into that directory.
  3. Rename .paket/paket.bootstrapper.exe to .paket/paket.exe. Read more about "magic mode".
  4. Commit .paket/paket.exe to your repository.
  5. After the first .paket/paket.exe invocation Paket will create a couple of files in .paket — commit those as well.

Specifying dependencies

Create a paket.dependencies file in your project's root and specify all your dependencies in it. You can use NuGet packages, Git repos, GitHub files and HTTP dependencies.

The file might look like this:

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

nuget Castle.Windsor-log4net >= 3.2
nuget NUnit

github forki/FsUnit FsUnit.fs

If you use a Paket plugin for your editor, you may get autocompletion for paket.dependencies file.

Read more about the importance and the structure of the paket.dependencies file. This file should be committed to your version control system.

Installing dependencies

Install all required packages from the specified sources:

1: 
.paket/paket.exe install

The paket install command will analyze your dependencies and automatically generate a paket.lock file:

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
NUGET
  remote: https://nuget.org/api/v2
    Castle.Core (3.3.3)
    Castle.Core-log4net (3.3.3)
      Castle.Core (>= 3.3.3)
      log4net (1.2.10)
    Castle.LoggingFacility (3.3.0)
      Castle.Core (>= 3.3.0)
      Castle.Windsor (>= 3.3.0)
    Castle.Windsor (3.3.0)
      Castle.Core (>= 3.3.0)
    Castle.Windsor-log4net (3.3.0)
      Castle.Core-log4net (>= 3.3.0)
      Castle.LoggingFacility (>= 3.3.0)
    log4net (1.2.10)
    NUnit (2.6.4)
GITHUB
  remote: forki/FsUnit
    FsUnit.fs (81d27fd09575a32c4ed52eadb2eeac5f365b8348)

This file shows all direct and transitive dependencies and pins every dependency to a concrete version. In most cases you want to commit this file to your version control system (read why).

Read more about the the paket.lock file. This file should be committed to your version control system.

Installing dependencies into projects

In the last paragraph you learned how to install packages into your repository, but usually you want to use the dependencies in your C#, VB or F# projects. In order to do so you need a paket.references files alongside your Visual Studio project files. By listing the direct dependencies in a paket.references file, Paket will automatically sync references to the corresponding projects whenever an install or update takes place.

1: 
2: 
3: 
4: 
Castle.Windsor-log4net
NUnit

File:FsUnit.fs .

Don't forget to run install again in order to let Paket reference the dependencies in your projects:

1: 
.paket/paket.exe install

Like all of the files above, you should commit paket.references file to your version control system.

Updating packages

If you want to check if your dependencies have updates you can run the paket outdated command:

1: 
.paket/paket.exe outdated

If you want to update all packages you can use the paket update command:

1: 
.paket/paket.exe update

This command will analyze your paket.dependencies file and update the paket.lock file.

Converting from NuGet

If you are already using NuGet and want to learn how to use the automatic NuGet conversion, then read the next tutorial.

Fork me on GitHub