Annoy.Net
1.1.0
dotnet add package Annoy.Net --version 1.1.0
NuGet\Install-Package Annoy.Net -Version 1.1.0
<PackageReference Include="Annoy.Net" Version="1.1.0" />
<PackageVersion Include="Annoy.Net" Version="1.1.0" />
<PackageReference Include="Annoy.Net" />
paket add Annoy.Net --version 1.1.0
#r "nuget: Annoy.Net, 1.1.0"
#:package Annoy.Net@1.1.0
#addin nuget:?package=Annoy.Net&version=1.1.0
#tool nuget:?package=Annoy.Net&version=1.1.0
Annoy.NET
Annoy.NET is a cross-platform C# wrapper for Spotify's Annoy. It can be used from Unity and from regular .NET applications through the Annoy.Net NuGet package.
Unity
- Download
annoy.net.unitypackagefrom the GitHub release assets. - Import it into your Unity project.
- Unity will install the wrapper under
Assets/Annoy.NET. - The release
unitypackageincludes the native plugins for Windows, Linux, and macOS.
NuGet
Install the managed wrapper and the platform-specific native library with:
dotnet add package Annoy.Net
The NuGet package ships native assets for win-x64, linux-x64, and osx-x64.
Usage
using System;
using UnityEngine;
using AnnoyWrapper;
public class Test : MonoBehaviour
{
void Start()
{
using (var index = Annoy.Index(512, AnnoyMetric.Angular))
{
Annoy.AddItem(index, 0, new float[512]);
Annoy.AddItem(index, 1, new float[512]);
Annoy.AddItem(index, 2, new float[512]);
Annoy.Build(index, 10);
Debug.Log(Annoy.GetNItems(index)); // 3
}
}}
Project Layout
dev.trainhead.annoy.net/contains the Unity-facing package content, samples, and Unity runtime tests.src/Annoy.Net/Annoy.Net.csprojexposes the same managed API for non-Unity consumers and produces theAnnoy.NetNuGet package.tests/Annoy.ManagedSmoke/contains a cross-platform .NET smoke test that runs against the native library.tests/Annoy.NuGetSmoke/validates the packaged.nupkgthrough a realPackageReference.
Setup & Build Instructions
- Clone this repository
git clone https://github.com/TrainHead-software/annoy.net.git
cd annoy.net
- Clone the Annoy source inside project folder
git clone https://github.com/spotify/annoy.git annoy
- Build the native library using CMake:
cmake -S annoy_clang -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
This produces annoy_c.dll on Windows, libannoy_c.so on Linux, and libannoy_c.dylib on macOS.
- Run the native and managed smoke tests:
ctest --test-dir build --output-on-failure
dotnet run --project tests/Annoy.ManagedSmoke/Annoy.ManagedSmoke.csproj
- Build the Unity package locally:
pwsh ./scripts/New-UnityPackage.ps1 -OutputPath ./dist/annoy.net.unitypackage -WindowsLibrary ./build/Release/annoy_c.dll
Add -LinuxLibrary and -MacLibrary when those binaries are available locally. In GitHub Actions, the release workflow injects all three native libraries automatically before publishing annoy.net.unitypackage.
- Build the NuGet package locally:
pwsh ./scripts/New-NuGetPackage.ps1 -OutputDirectory ./dist/nuget -WindowsLibrary ./build/Release/annoy_c.dll
Add -LinuxLibrary and -MacLibrary when those binaries are available locally. On tagged releases, GitHub Actions builds the .nupkg, attaches it to the GitHub release, and publishes it to NuGet.org when NUGET_API_KEY is configured.
License
This project includes and wraps Spotify Annoy, a C++ library for approximate nearest neighbors.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.0 | 118 | 3/17/2026 |