Xray.Sdk
0.0.14-beta
dotnet add package Xray.Sdk --version 0.0.14-beta
NuGet\Install-Package Xray.Sdk -Version 0.0.14-beta
<PackageReference Include="Xray.Sdk" Version="0.0.14-beta" />
<PackageVersion Include="Xray.Sdk" Version="0.0.14-beta" />
<PackageReference Include="Xray.Sdk" />
paket add Xray.Sdk --version 0.0.14-beta
#r "nuget: Xray.Sdk, 0.0.14-beta"
#:package Xray.Sdk@0.0.14-beta
#addin nuget:?package=Xray.Sdk&version=0.0.14-beta&prerelease
#tool nuget:?package=Xray.Sdk&version=0.0.14-beta&prerelease
Xray.Sdk - xray-cshare C-share compatible
Xray.Sdk is a .NET 9 solution for building, running, and controlling xray-core from managed code. Native-library hosting is built to work with the C-share library from xray-cshare.
The solution is split into three focused libraries:
Xray.Config: strongly typed configuration models, JSON serialization, and share-link helpers.Xray.Api: gRPC client wrappers and convenience methods for runtime management.Xray.Core: process-based and native-library-based runtime hosting helpers.
Compatibility changes are recorded in CHANGELOG.md.
Language
- English project docs are the primary reference.
- Russian translations are provided next to each project guide.
Documentation
Solution Overview
- This file: README.md
- Example app: Program.cs
- Tests:
Xray.Sdk.Tests
Project Guides
Xray.Api- English: API_README.md
- Russian: RU_API_README.md
Xray.Config- English: CONFIG_README.md
- Russian: RU_CONFIG_README.md
Xray.Core- English: CORE_README.md
- Russian: RU_CORE_README.md
Repository Layout
Xray.Sdk/
|- Xray.Api/
|- Xray.Config/
|- Xray.Core/
|- Xray.Sdk.Example/
|- Xray.Sdk.Tests/
|- Fetch-XrayProtos.ps1
`- Xray.Sdk.sln
What Each Library Does
Xray.Config
Use this package when you need to:
- build Xray configuration files in C#
- deserialize existing Xray JSON
- round-trip supported config formats
- convert supported share links into typed outbound models
Xray.Api
Use this package when you need to:
- call Xray gRPC services
- query runtime stats
- manage inbounds and outbounds
- add and remove users without manually building protobuf payloads
Xray.Core
Use this package when you need to:
- start
xray-coreas an external process - host the native Xray library in-process
- generate keys and certificates through native helpers
- run lightweight health or ping-style checks against a config
Quick Start
Build the solution:
dotnet build Xray.Sdk.sln -c Release
Run tests:
dotnet test Xray.Sdk.Tests/Xray.Sdk.Tests.csproj -c Release
Add one of the projects as a reference:
dotnet add <YourProject>.csproj reference Xray.Config/Xray.Config.csproj
dotnet add <YourProject>.csproj reference Xray.Api/Xray.Api.csproj
dotnet add <YourProject>.csproj reference Xray.Core/Xray.Core.csproj
Minimal Example
using Xray.Config.Enums;
using Xray.Config.Models;
var config = new XrayConfig
{
Log = new LogConfig
{
LogLevel = LogLevel.Warning,
},
Inbounds =
[
new SocksInbound
{
Tag = "socks-in",
Listen = "127.0.0.1",
Port = new Port(10808),
Settings = new Inbound.SocksSettings
{
Udp = true,
}
}
],
Outbounds =
[
new FreedomOutbound
{
Tag = "direct",
}
]
};
var json = config.ToJson();
For runtime hosting and API usage, see the project-specific guides and the example app in Program.cs.
Compatibility Notes
- The solution targets
.NET 9.0. Xray.Apidepends on generated protobuf clients from theXray-Protosfolder.Xray.Api/Xray-Protosis verified againstxray-corev26.3.27.Xray.Config.SupportedCoreVersionRangereturns the SDK-audited xray-core range. This is not the same as the Xray config fileversionruntime gate.Xray.Coresupports both process-hosted and native-library-hosted execution, but native integration still depends on matching platform binaries.Xray.Configfocuses on typed support for known Xray formats; unsupported or newly added upstream fields may require updates in the SDK.
Development
Useful commands:
dotnet build Xray.Sdk.sln -c Release
dotnet test Xray.Sdk.Tests/Xray.Sdk.Tests.csproj -c Release
dotnet pack Xray.Sdk/Xray.Sdk.csproj -c Release
Packages are written to artifacts/packages.
The publishable NuGet package is Xray.Sdk. It contains the API, Config, and Core assemblies in one package.
Publish the package to NuGet:
dotnet nuget push artifacts/packages/Xray.Sdk.0.0.12-beta.nupkg --api-key <NUGET_API_KEY> --source https://api.nuget.org/v3/index.json
GitHub Actions NuGet Publishing
The repository includes a GitHub Actions workflow that builds, tests, packs, and publishes Xray.Sdk.
Required repository secret:
NUGET_API_KEY: NuGet API key with permission to publish theXray.Sdkpackage.
Pull requests and pushes to main build, test, pack, and upload package artifacts. Publishing to NuGet runs only when a version tag is pushed:
git tag v0.0.12-beta
git push origin v0.0.12-beta
The package version is resolved from the tag name without the leading v, so v0.0.12-beta publishes package version 0.0.12-beta.
License
This repository is distributed under the MIT license.
Package metadata also declares MIT:
Contributing
- keep public APIs typed and explicit
- add or update tests in
Xray.Sdk.Tests - document behavioral changes in the relevant project guide
- record user-visible changes in
CHANGELOG.md - preserve compatibility with
xray-coreformats where possible
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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. |
-
net9.0
- Google.Protobuf (>= 3.33.2)
- Grpc.Net.Client (>= 2.71.0)
- YamlDotNet (>= 16.3.0)
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 |
|---|---|---|
| 0.0.14-beta | 69 | 8/19/2026 |
| 0.0.13-beta | 92 | 7/12/2026 |
| 0.0.12-beta | 78 | 7/10/2026 |
| 0.0.11-beta | 68 | 7/8/2026 |
| 0.0.9-beta | 71 | 7/7/2026 |
| 0.0.8-beta | 82 | 6/27/2026 |
| 0.0.7-beta | 69 | 5/16/2026 |
| 0.0.6-beta | 74 | 5/15/2026 |
| 0.0.5-beta | 70 | 5/15/2026 |
| 0.0.4-beta | 67 | 5/13/2026 |
| 0.0.2-beta | 171 | 4/25/2026 |
| 0.0.1-beta | 72 | 4/25/2026 |