C# Runtime
C# runtime requirements, setup, and gotchas for poly-bench
This guide walks through using C# with poly-bench, from init through run. It covers what gets created, how dependencies work, and common gotchas.
You need the .NET SDK installed and available on your PATH. The table below summarizes the requirements.
| Requirement | Details |
|---|---|
| Binary | dotnet on PATH |
| Version | .NET 8.0+ (SDK) |
| Verify | dotnet --version |
Install from dot.net. If .NET is missing when you run init, poly-bench can offer to install it interactively during poly-bench init.
When you run poly-bench init --languages csharp (or select C# in the interactive flow), poly-bench creates a .NET project under .polybench/runtime-env/csharp/:
1.polybench/runtime-env/csharp/2├── polybench.csproj3├── Program.cs4├── global.json5└── NuGet.configThe target framework defaults to net8.0. If you need a different version, you can override it in the project manifest:
1[csharp]2target_framework = "net9.0"poly-bench writes a global.json file to pin the SDK version — for example, 8.0.0 for net8.0. This ensures that dotnet build uses the correct SDK.
To add NuGet packages, use the add command with the --cs flag:
$poly-bench add --cs Newtonsoft.Json@13.0.3The spec format is package@version — for example, Newtonsoft.Json@13.0.3. Dependencies are stored in the manifest and added to the .csproj file.
The NuGet.config adds the vs-impl feed for roslyn-language-server; some LSP setups need this feed.
Running poly-bench install (or poly-bench build) runs dotnet restore to fetch NuGet packages.
When you run poly-bench run, poly-bench generates C# code and compiles with dotnet build. The global.json pin ensures the correct SDK is used.
net8.0. Override in polybench.toml: [csharp] target_framework = "net9.0"target_framework = "net6.0" or net7.0 in polybench.toml.global.json to pin SDK (e.g. 8.0.0 for net8.0). Ensures dotnet build uses correct SDK.