Annoy.Net 1.1.0

dotnet add package Annoy.Net --version 1.1.0
                    
NuGet\Install-Package Annoy.Net -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Annoy.Net" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Annoy.Net" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Annoy.Net" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Annoy.Net --version 1.1.0
                    
#r "nuget: Annoy.Net, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Annoy.Net@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Annoy.Net&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Annoy.Net&version=1.1.0
                    
Install as a Cake Tool

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

  1. Download annoy.net.unitypackage from the GitHub release assets.
  2. Import it into your Unity project.
  3. Unity will install the wrapper under Assets/Annoy.NET.
  4. The release unitypackage includes 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.csproj exposes the same managed API for non-Unity consumers and produces the Annoy.Net NuGet package.
  • tests/Annoy.ManagedSmoke/ contains a cross-platform .NET smoke test that runs against the native library.
  • tests/Annoy.NuGetSmoke/ validates the packaged .nupkg through a real PackageReference.

Setup & Build Instructions

  1. Clone this repository
git clone https://github.com/TrainHead-software/annoy.net.git
cd annoy.net
  1. Clone the Annoy source inside project folder
git clone https://github.com/spotify/annoy.git annoy
  1. 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.

  1. Run the native and managed smoke tests:
ctest --test-dir build --output-on-failure
dotnet run --project tests/Annoy.ManagedSmoke/Annoy.ManagedSmoke.csproj
  1. 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.

  1. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .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