Building Ice for C# from source

January 23, 2026 ยท View on GitHub

Prerequisites

  1. .NET SDK 10.0
    Download the .NET SDK from dotnet.microsoft.com.

  2. The Slice to C# compiler (slice2cs) from the C++ source distribution.

  3. Python 3.12 is required for running the tests. The Glacier2 test also require the passlib Python package.

  4. docfx (optional) The API reference is generated by docfx. You can install docfx as follows:

    dotnet tool update -g docfx
    

Build roadmap

flowchart LR
    compiler(slice2cs) --> slice-tools(ZeroC.Ice.Slice.Tools) --> ice(ZeroC.*<br>iceboxnet)
    ice -- doc --> api(API reference)
    ice -- pack/publish --> nuget(NuGet packages)
    ice --> tests(Tests)

Building Ice for C#

Before building Ice for C#, you must first build the slice2cs Slice compiler from the Ice C++ source distribution. Refer to the build instructions in the cpp subdirectory for details on how to build the C++ source distribution.

Once slice2cs is available, open a command prompt and navigate to the csharp subdirectory. To build the Slice tools, all Ice for C# assemblies, and the test suite, run the following command:

dotnet msbuild msbuild/ice.proj

Running the Tests

To run the tests, open a command prompt and change to the csharp subdirectory. At the command prompt, execute:

python allTests.py --all

If everything worked out, you should see lots of ok messages. In case of a failure, the tests abort with failed.

Creating and publishing NuGet packages

To create the NuGet packages, open a command prompt and run the following command:

dotnet msbuild msbuild/ice.proj /t:Pack

This command creates all the NuGet packages.

You can publish these packages to your local global-packages source with the following command:

dotnet msbuild msbuild/ice.proj /t:Publish

Slice tools

By default, the NuGet package ZeroC.Ice.Slice.Tools includes only the slice2cs compiler created by the local build.

If you set the MSBuild property SLICE2CS_STAGING_PATH, ZeroC.Ice.Slice.Tools includes the slice2cs compiler for all supported platforms. The expected layout of the staging directory is <os-name>-<os-arch>/<compiler-executable>, with the following subdirectories:

  • linux-x64: Linux x86_64
  • linux-arm64: Linux ARM64
  • macos-arm64: macOS Apple silicon
  • windows-x64: Windows x64

Make sure that all these compilers are available when you set SLICE2CS_STAGING_PATH.

Generating the API reference

The API reference can be generated by running the following command in the docfx subdirectory:

docfx metadata --property Configuration=Release
docfx build

This command generates the API reference into the docfx\_site directory. Start a local web server to view this API reference:

docfx serve docfx/_site