C#

Build dependencies:

  • .NET 7 SDK

.NET 7 is needed only to build from source; the compiled binaries support at minimum .NET 5.

Build

Building TileDB-CSharp from source can be done using the following commands in a cloned repository.

$ cd TileDB-CSharp/sources/TileDB.CSharp/
$ dotnet build -c Release

As a final build step, we can verify our installation by running unit tests

$ cd ../../tests/TileDB.CSharp.Test/
$ dotnet test -c Release

Development

To help get started using TileDB-CSharp we can run the TileDB.CSharp.Example project:

$ cd TileDB-CSharp/examples/TileDB.CSharp.Example/
$ dotnet run --framework net5.0

After the TileDB.CSharp project is built and tests are passing we can make a new .NET project and add a reference to TileDB.CSharp, granting us access to the TileDB-CSharp API.

# Create a new .NET solution
$ dotnet new sln -o TileDB-Project
$ cd TileDB-Project
# Create a new console project using .NET CLI
$ dotnet new console -o ConsoleApp
$ dotnet sln add ConsoleApp/ConsoleApp.csproj
# Add TileDB.CSharp project to ConsoleApp as reference
$ dotnet add ConsoleApp/ConsoleApp.csproj reference /path/to/TileDB-CSharp/sources/TileDB.CSharp/TileDB.CSharp.csproj

Resulting in TileDB-Project/ConsoleApp/ConsoleApp.csproj generating the following configuration:

<Project Sdk="Microsoft.NET.Sdk">
  <ItemGroup>
    <ProjectReference Include="..\sources\TileDB.CSharp\TileDB.CSharp.csproj" />
  </ItemGroup>
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <!-- Don't forget to add the following line: -->
    <UseCurrentRuntimeIdentifier>true</UseCurrentRuntimeIdentifier>
  </PropertyGroup>
</Project>

Using custom native libraries

The TileDB.CSharp project uses the official native binaries from NuGet. You can during development provide your own native library for purposes like testing. To do that, you have to go to the Directory.Packages.props file of your repository, and set the LocalLibraryFile property to the path of your local native binary. This will bypass the standard acquisition mechanism and simply copy the libeary to your project's output directory.

The shipped TileDB.CSharp NuGet package supports only the official native binaries at the moment. Please contact us or open a GitHub issue if you want to use TileDB from C# with custom native binaries.

Last updated