This project provides the server and conversion tooling that makes a curated catalog of NuGet packages available within the Unity Package Manager.
The public package catalog is maintained in the OpenUPM UnityNuGet registry.
Important
This is not an official service provided by Unity Technologies Inc.
Note
Feed provided by OpenUPM.
In order to use this service you simply need to add a UPM scoped registry.
You can do this in several ways:
Manually edit your project's Packages/manifest.json file to look like the following:
{
"scopedRegistries": [
// Other registries...
{
"name": "Unity NuGet",
"url": "https://unitynuget-registry.openupm.com",
"scopes": [
"org.nuget"
]
}
],
"dependencies": {
// Other dependencies...
"org.nuget.scriban": "2.1.0"
}
}Alternatively, follow Unity's instructions to add the scoped registry via the Package Manager UI, with the following values:
Name: Unity NuGet
Url: https://unitynuget-registry.openupm.com
Scope(s): org.nugetImportant
In Unity 2022.2+, this is the default behavior, so no action is required.
This step is necessary to ensure that binding redirects for strongly named assemblies in NuGet packages resolve correctly to paths within the Unity project.
For earlier Unity versions, uncheck Project Settings > Player > Other Settings > Configuration > Assembly Version Validation.
Warning
If you are encountering weird compilation errors with UnityNuGet and you have been using UnityNuGet already,
it could be that we have updated packages on the server, and in that case, you need to clear the cache containing
all Unity NPM packages downloaded from the registry.
On Windows, this cache by default is located at: %LOCALAPPDATA%\Unity\cache\npm
See the cache locations by OS.
Warning
You may also experience timeouts when installing UnityNuGet packages, with a message like:
[Package Manager Window] Error adding package: org.nuget.microsoft.extensions.logging.abstractions@6.0.0. connect ETIMEDOUT 143.244.220.150:443 UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
Verify that you are using the new OpenUPM-based URL and not the old Azure Websites URL. You can also check OpenUPM Status to see if OpenUPM itself is having an outage.
When opening the Package Manager Window, you should see a few packages coming from NuGet with the postfix text (NuGet), like in this screenshot:
Package catalog contributions now belong in the openupm/unitynuget-registry repository.
Open a pull request there to add or update a package. Its README documents the package rules and the complete contribution process. Pull requests run unityNuGet validate on changed entries, and passing pure additions can be merged automatically.
Only compatible with Unity 2019.1 and potentially with newer version.
Note
This service is currently tested with Unity 2019.x, 2020.x, 2021.x, 2022.x, 2023.x and 6000.0.x.
It may not work with a more recent version of Unity.
To have more control of the server, it is recommended to host the service on your own. This way you can decide which specific packages to include in the registry.json file which makes the server lighter.
This project publishes a Docker image in ghcr.io that can be consumed to create a container and host it as you wish:
There is a complete example with all available options in examples/docker.
Packages are signed using the upm pack command.
To do this, you need to set the following environment variables. They are defined in the Prerequisites section of this page:
Signing:UpmServiceAccountKeyId
Signing:UpmServiceAccountKeySecret
Signing:UnityOrganizationId
If these variables are set, the packages will be signed automatically.
Note
The Azure DevOps PAT must have Packaging (Read) permissions.
As documented in the example, it is possible to provide a custom NuGet.Config file.
To add a private feed, the following fields must be filled in:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="MyCustomFeed" value="https://pkgs.dev.azure.com/<ORG_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/nuget/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<MyCustomFeed>
<add key="Username" value="<Azure DevOps Email>" />
<add key="ClearTextPassword" value="<Azure DevOps PAT>" />
</MyCustomFeed>
</packageSourceCredentials>
</configuration>UnityNuGet is also distributed as a dotnet tool. The difference is that in this case it does not act as a server but as a process that processes all the packages in registry.json in one pass.
This use case is useful when you simply don't want to depend on an external server and want your dependencies to be local packages.
To use it, once installed with dotnet tool install -g UnityNuGet.Tool simply run the command unityNuGet.
Note that an
appsettings.jsonfile must exist in the working directory from which the command is executed. ItsRegistry:RegistryFilePathsetting must point to aregistry.jsonfile that you provide (by default,registry.jsonin the working directory).
To validate a registry.json file without needing an appsettings.json (for example in PR CI), use the validate subcommand:
unityNuGet validate <registry-json-path> [--package <id> ...] [--filter <regex>] [--all] [--skip-conversion]
- Without
--package,--filter, or--all,validateruns fast static checks (JSON validity, duplicate keys, alphabetical order,.NETStandard2.0built-in exclusion, and requiredversion). - With
--package(repeatable, exact match) or--filter,validatealso checks online NuGet minimum compatible versions (>=) and runs a package conversion test against the fullregistry.jsondependency graph.
It is hosted by OpenUPM.
The reason is that many NuGet packages are not compatible with Unity, or do not provide .NETStandard2.0 or .NETStandard2.1 assemblies or are not relevant for being used within Unity.
Since 2019.1.x, Unity is compatible with .NETStandard2.0 and it is the .NET profile that is preferred to be used.
Having a .NETStandard2.0 for NuGet packages for Unity can ensure that the experience to add a package to your project is consistent and well supported.
As of Unity 2021.x it also supports .NETStandard2.1 so packages providing this target will be compatible with this version of Unity or newer.
See Unity's documentation on .NET profile support.
This project implements a simplified compatible NPM server in C# using ASP.NET Core and converts NuGet packages to Unity packages before serving them.
At a threshold defined by UpdateInterval (10 minutes by default), packages are updated from NuGet so that if a new version is published, from the curated list of NuGet packages, it will be available through this service.
Once converted, these packages are cached on the disk on the server.
See the analyzer-specific page in the repository below:
This software is released under the BSD-Clause 2 license.
Alexandre Mutel aka xoofx
Borja Domínguez aka bdovaz

