Skip to content

Instantly share code, notes, and snippets.

@jeremyabbott
Last active August 2, 2018 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremyabbott/cc04ecbf67656d4465bdd0cd1cf1e135 to your computer and use it in GitHub Desktop.
Save jeremyabbott/cc04ecbf67656d4465bdd0cd1cf1e135 to your computer and use it in GitHub Desktop.
Paket Notes

Paket Notes

Useful commands

Add source credentials

paket config add-credentials <url> --username <name> --password <password> --verify

Add package to project

paket add <PackageId> --project .\src\App\App.csproj

This will add the package to the paket.references for the project (paket.references should in the same directory as the project file), add the package to paket.dependencies and update paket.lock with the transitive dependencies for the package.

Relevant Files

File Notes
paket.lock This file defines the full dependency graph for all of your dependencies. It's created/modified when running paket install or paket update. This file lives at the root of your project. There is only 1 paket.lock file.
paket.dependencies This file defines the direct dependencies for your project. You can specify dependencies in groups, and have different sources per group. Sources can be nuget feeds, github gists, or direct http dependencies. There is only 1 paket.dependencies file. Package versions can be specified here.
paket.references This file defines the depencies for an MSBuild project (.xxproj). It is similar to the old school packages.config or the "new" <ProjectReference /> tags in SDK based projects. There can be any number of these files underneath paket.dependencies. You DO NOT specify versions in this file.

Folder Structure

.paket
|__paket.exe
|__Paket.Restore.targets
paket.lock
paket.references
|__Dir1
|  |__paket.dependencies
|  |__Lib.csproj
|__Dir2
   |__paket.dependencies
   |__App.fsproj

Example Project File

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="Program.fs" />
  </ItemGroup>
  <!-- dotnet restore will use Paket.Restore.targets file to build out project.assets.json and other msbuild dependencies -->
  <Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>

Example paket.references

group Server
  FSharp.Core
  Saturn

Example paket.dependencies

group Server
  source https://api.nuget.org/v3/index.json

  nuget FSharp.Core
  nuget Saturn
  nuget Fable.JsonConverter

Commands that Update paket.lock

Command Modifies paket.lock Notes
Install Yes Only if paket.dependencies has changed
Update Yes Deletes paket.lock, gets latest version of packages in paket.dependencies, rebuilds paket.lock
Restore No Downloads dependencies as defined in paket.lock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment