Skip to content

Instantly share code, notes, and snippets.

@marcolink
Last active August 23, 2017 12:36
Show Gist options
  • Save marcolink/653a3d0b9208b6e6c1b8775f491756d1 to your computer and use it in GitHub Desktop.
Save marcolink/653a3d0b9208b6e6c1b8775f491756d1 to your computer and use it in GitHub Desktop.
Paket Dependency Management For Unity

Paket Dependency Management For Unity

We use a combination of Paket and Paket.Unity3D in our projects for internal dependency management. There is also a wrapper called Wooget for both, but since we don't maintain it anymore, i will not cover it.

We always need 2 steps to update depenencies:

  • Paket to Install all defined depenency for your project.
  • Paket.Unity3D to add them to the Unity Project.

The Documentation is based on the recommended project structure.

General

Gradle paket support

There is a new repository atlas-paket for paket support with gradle. I highly recommend to use this plugin if you use paket and gradle (specially on build machines).

Install Paket

https://fsprojects.github.io/Paket/installation.html or just run

brew install paket

Using brew will ensure mono is installed since it's defined as dependency.

I recommend to download and copy paket.bootstrapper.exe into .paket and renamed to paket.exe. This will automatically download the latest version into a temp file, and execute your command. With this, you don't have to add a fixed version of paket to your project, and the executable binary has only ~56kb instead of >6.5MB (Basically the same behaviour as the gradle wrapper).

Install Paket.Unity3D

https://github.com/wooga/Paket.Unity3D/releases You can also just copy it from an existing project to your local .paket folder.

Recommended project structure with Unity

.
├── paket.dependencies
├── paket.lock (automatically created)
├── packages (created by paket, not under vc)
├── .paket
|   ├── paket.exe
|   ├── paket.unit3d.exe
├── Unity-Project-Directory
|   ├── paket.unity3d.references
|   ├── paket.template (only for distribution)
|   ├── Assets/Paket.Unity3D

Init Paket project

paket init
  • will create a .paket folder with paket.exe (which is actually a renamed paket.bootstrapper.exe)
  • will create an empty paket.dependencies file.

Define sources and dependencies

All sources and dependencies are defined in paket.dependencies. First define all sources you need:

source https://nuget.org/api/v2

Then add depenencies:

nuget Wooga.Services

To identify the right source and depenency, check one of the existing games as reference.

Install dependencies

mono .paket/paket.exe install

Download the dependencies specified by the paket.dependencies or paket.lock file into the packages directory and update projects.

you can also use mono paket.exe restore to unly download dependencies specified in paket.lock.

Update dependencies

mono .paket/paket.exe update

Install vs. Update:

paket update will ignore paket.lock file, and pull the latest allowed version in paket.dependencies, while paket install will pull the version locked in paket.lock file.

Install Unity Paket dependencies

Define dependencies for Unity Project

Before using paket.unity3d.exe, we have to create a paket.unity3d.references file next to Assets folder manually.

Wooga.Services

Define without version

Installing dependencies into Unity project

mono .paket/paket.unity3d.exe install

this will extract all dependencies defined in paket.unity3d.references in your unity project.

Distributing with Paket

The paket.template file

Basic setup looks like:

type file
id Wooga.MySDK
owners Wooga
authors Marco Link
projectUrl
    https://github.com/wooga/wdk-unity-Wooga.MySDK
iconUrl
    http://wooga.github.io/wdk-unity-Wooga.MySDK/img/logo.png
licenseUrl
    https://github.com/wooga/wdk-unity-CoreServices/blob/master/LICENSE.txt
requireLicenseAcceptance
    false
copyright
    Copyright 2017
tags
    wdk
summary
    My Wooga SDK
description
    My Wooga SDK Description
files
    Assets/Wooga/**/* ==> content
    !../**/AssemblyInfo.cs
    ../README.md ==> content
dependencies
    Wooga.AnotherSDK ~> 1.1.0
    

You can find all the Details here!

Pack a local Package for testing

paket pack output ../test/bin version 0.0.1 -v
@Larusso
Copy link

Larusso commented Jul 3, 2017

https://github.com/wooga/Paket.Unity3D/releases/download/0.2.1/paket.unity3d.bootstrapper.exe has a bootstrapper too.
this one should be added to the project.

@Larusso
Copy link

Larusso commented Jul 3, 2017

Paket commands:

  • paket install Download the dependencies specified by the paket.dependencies or paket.lock file into the packages/ directory and update projects.
  • paket restore Download the dependencies specified by the paket.lock file into the packages/ directory.

@Larusso
Copy link

Larusso commented Jul 3, 2017

paket pack works only with paket.template files: https://fsprojects.github.io/Paket/template-files.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment