--- title: C# | Stainless description: Generate production-ready C# SDKs from your OpenAPI specification --- C# is [fully supported](https://www.stainless.com/changelog/c-sdk-generator-is-generally-available). The Stainless C# SDK generator creates idiomatic, type-safe C# client libraries from your OpenAPI specification. **Example repositories:** - [anthropics/anthropic-sdk-csharp](https://github.com/anthropics/anthropic-sdk-csharp) - [trycourier/courier-csharp](https://github.com/trycourier/courier-csharp) - [ArcadeAI/arcade-dotnet](https://github.com/ArcadeAI/arcade-dotnet) ## Configuration To generate a C# SDK, add the `csharp` target to your Stainless configuration file: ``` targets: csharp: package_name: MyCompany.Client edition: csharp.2025-10-08 ``` ### Common configuration options ``` targets: csharp: package_name: MyCompany.Client # Specify the edition edition: csharp.2025-10-08 # Configure publishing publish: nuget: true ``` For a complete list of configuration options, see the [C# target reference](/docs/reference/config#csharp/index.md). ### Strong named assemblies [Strong-named assemblies](https://learn.microsoft.com/en-us/dotnet/standard/assembly/strong-named) are a .NET mechanism to give assemblies a unique ID. This provides several benefits, including the ability to have your assembly installed in the [global assembly cache](https://learn.microsoft.com/en-us/dotnet/framework/app-domains/gac). Although strong-naming uses cryptographic signatures, it is not intended to be used as a security mechanism. Microsoft recommends [adding your public and private keys to your repository](https://learn.microsoft.com/en-us/dotnet/standard/library-guidance/strong-naming) which Stainless will automatically do for you. To enable strong-named assemblies, you will need a base64-encoded assembly originator key and corresponding public key. You can generate these keys on a Linux or Mac system (or on WSL) using the following commands: Terminal window ``` export TEMP_SNK=$(mktemp) sn -k $TEMP_SNK cat $TEMP_SNK | base64 -w 1000 # this is your base64-encoded assembly originator key sn -tp $TEMP_SNK | grep -oE '^[0-9a-f]+$' | tr -d '\n'; echo # this is your public key rm $TEMP_SNK # cleanup ``` Once you have your keys, add them to your Stainless config like so: ``` targets: csharp: ... strong_name: originator_key: foo # your base64-encoded assembly originator key public_key: bar # your public key ``` When you add those keys to your Stainless config, an `Open.snk` file will be added to your C# repository automatically, and strong-name signing will be enabled at build and publish time. ## Editions Editions allow Stainless to make improvements to SDKs that aren’t backwards-compatible. You can explicitly opt in to new editions when you’re ready. See the [SDK and config editions reference](/docs/reference/editions/index.md) for more information. #### csharp.2025-10-08 - Initial edition for C# (used by default if no edition is specified) ## Publishing to NuGet Publish your C# SDK to [NuGet](https://www.nuget.org/) for distribution. Before publishing, you need to [link a production repository](/docs/guides/publish#link-production-repos/index.md) where Stainless will push your SDK code. Get an API token 1. Log in or sign up at [NuGet](https://www.nuget.org). 2. Select your username at the top right to open a dropdown. 3. Navigate to **API Keys**. 4. Create a new API key with the **Push new packages and package versions** privilege. Under **Select Packages**, either enter your package name or a glob (e.g. ”\*”). Add the token to your production repo 1. In your production repo, navigate to **Secrets and variables** > **Actions** > **New repository secret**. The URL should look like `https://github.com///settings/secrets/actions/new`. 2. Add a new secret named `NUGET_API_KEY` with your API token. Choose a package name and update your Stainless config 1. Choose an available package name. Suggested names are: - `` - `.Client` You can check whether the name is available by testing the link at `https://www.nuget.org/packages/`. 2. Update the [Stainless config](/docs/reference/config#csharp/index.md) with your package name and save. ``` targets: csharp: package_name: publish: nuget: true ```