Unclaimed Package Is this your package? Claim it to unlock full analytics and manage your listing.
Claim This Package

Install via UPM

Add to Unity Package Manager using this URL

https://www.pkglnk.dev/nuget-integrator.git

README Markdown

Copy this to your project's README.md

Style
Preview
pkglnk installs badge
## Installation

Add **NuGet Integrator** to your Unity project via Package Manager:

1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/nuget-integrator.git
```

[![pkglnk](https://www.pkglnk.dev/badge/nuget-integrator.svg?style=pkglnk)](https://www.pkglnk.dev/pkg/nuget-integrator)

README

NuGet Integrator for Unity

A lightweight way of referencing NuGet dependencies in Unity projects. Basic idea borrowed from toitnups.

Basically, we keep an integration.csproj (targeting netstandard2.0) inside the Unity project, add the needed dependencies to it and, when it is published, the DLL's are copied to the Assets folder.

Requirements

Installation options

openupm add com.bassarisse.nuget-integrator

Basic usage

  • After installing, run the menu item NuGet > Create Integration Project so you can add your dependencies to it.
  • To add a new dependency, run via command-line, from the project root:
dotnet add NuGetIntegration/integration.csproj package [package-id]
  • Every time a new NuGet dependency is added, you should run the menu item NuGet > Restore Dependencies. That's it!

Extra configuration

  • Update versioning settings
    • The folder where the dependencies are placed (Assets/NuGetPackages) should be ignored from versioning.
    • Normally *.csproj files are already ignored in Unity projects, so you need to make an exception for the integration file.
    • .gitignore example:
# NuGet integration proj
!**/NuGetIntegration/integration.csproj

# NuGet packages in Unity
**/[Aa]ssets/NuGetPackages/*
**/[Aa]ssets/NuGetPackages.meta

Caveats & CI/CD considerations

  • Since Unity knows nothing about the integration, before opening (or building) your project you should restore the NuGet dependencies "manually" by running:
dotnet publish NuGetIntegration/integration.csproj -c Release
  • On macOS, I could not run the dotnet command via Unity, so the executable location is hard-coded, considering the default installation path.

To-do

  • Detect changes & restore the packages when needed, automatically
  • UI for adding & searching for dependencies via Unity
  • UI to add custom package sources

Alternatives

Comments

No comments yet. Be the first!