This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory.git
The following commit(s) were added to refs/heads/main by this push:
new da1c5e9fb chore(c#): prepare for c# release (#3464)
da1c5e9fb is described below
commit da1c5e9fb72fcdf03cda05b623783fc498939c7b
Author: Shawn Yang <[email protected]>
AuthorDate: Tue Mar 10 17:49:05 2026 +0800
chore(c#): prepare for c# release (#3464)
## Why?
## What does this PR do?
#3387
## Related issues
## Does this PR introduce any user-facing change?
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
---
.gitignore | 1 +
ci/publish-nuget.sh | 89 +++++++++++++++++++++++
csharp/Directory.Build.props | 17 +++++
csharp/README.md | 23 ++++--
csharp/src/Fory.Generator/Fory.Generator.csproj | 3 +-
csharp/src/Fory/Fory.csproj | 21 +++++-
csharp/tests/Fory.XlangPeer/Fory.XlangPeer.csproj | 3 +-
docs/guide/csharp/index.md | 10 +++
8 files changed, 158 insertions(+), 9 deletions(-)
diff --git a/.gitignore b/.gitignore
index fbc9ee0e2..73be8ed90 100644
--- a/.gitignore
+++ b/.gitignore
@@ -119,5 +119,6 @@ csharp/tests/Fory.Tests/bin/
csharp/tests/Fory.Tests/obj/
csharp/tests/Fory.XlangPeer/bin/
csharp/tests/Fory.XlangPeer/obj/
+csharp/artifacts/
tasks/
diff --git a/ci/publish-nuget.sh b/ci/publish-nuget.sh
new file mode 100755
index 000000000..45201daf8
--- /dev/null
+++ b/ci/publish-nuget.sh
@@ -0,0 +1,89 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -euo pipefail
+
+script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+repo_root="$(cd "$script_dir/.." && pwd)"
+csharp_dir="$repo_root/csharp"
+version="$(
+ sed -n 's:.*<Version>\(.*\)</Version>.*:\1:p'
"$csharp_dir/Directory.Build.props" | head -n 1
+)"
+package_id="Apache.Fory"
+package_name="$package_id.$version"
+output_dir="$csharp_dir/artifacts/nuget"
+package_source="${NUGET_SOURCE:-https://api.nuget.org/v3/index.json}"
+symbol_source="${NUGET_SYMBOL_SOURCE:-$package_source}"
+
+if [[ -z "$version" ]]; then
+ echo "Could not resolve <Version> from $csharp_dir/Directory.Build.props."
>&2
+ exit 1
+fi
+
+if ! command -v dotnet >/dev/null 2>&1; then
+ echo "dotnet SDK 8.0+ is required." >&2
+ exit 1
+fi
+
+if [[ -z "${NUGET_API_KEY:-}" ]]; then
+ echo "Set NUGET_API_KEY before publishing." >&2
+ exit 1
+fi
+
+rm -rf "$output_dir"
+mkdir -p "$output_dir"
+
+echo "Restoring C# solution..."
+dotnet restore "$csharp_dir/Fory.sln"
+
+echo "Running C# tests..."
+dotnet test "$csharp_dir/Fory.sln" -c Release --no-restore
+
+echo "Packing $package_id $version..."
+dotnet pack "$csharp_dir/src/Fory/Fory.csproj" \
+ -c Release \
+ --no-restore \
+ -o "$output_dir" \
+ -p:ContinuousIntegrationBuild=true
+
+package_path="$output_dir/$package_name.nupkg"
+symbols_path="$output_dir/$package_name.snupkg"
+
+if [[ ! -f "$package_path" ]]; then
+ echo "Expected package not found: $package_path" >&2
+ exit 1
+fi
+
+if [[ ! -f "$symbols_path" ]]; then
+ echo "Expected symbol package not found: $symbols_path" >&2
+ exit 1
+fi
+
+echo "Publishing $package_name.nupkg..."
+dotnet nuget push "$package_path" \
+ --api-key "$NUGET_API_KEY" \
+ --source "$package_source" \
+ --skip-duplicate
+
+echo "Publishing $package_name.snupkg..."
+dotnet nuget push "$symbols_path" \
+ --api-key "$NUGET_API_KEY" \
+ --source "$symbol_source" \
+ --skip-duplicate
+
+echo "Published $package_name to NuGet."
diff --git a/csharp/Directory.Build.props b/csharp/Directory.Build.props
new file mode 100644
index 000000000..d698ebbf5
--- /dev/null
+++ b/csharp/Directory.Build.props
@@ -0,0 +1,17 @@
+<Project>
+ <PropertyGroup>
+ <Version>0.1.0</Version>
+ <Authors>Apache Software Foundation</Authors>
+ <Company>Apache Software Foundation</Company>
+ <Description>Apache Fory for .NET provides high-performance cross-language
serialization with source-generated serializers and schema evolution
support.</Description>
+ <PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
+ <PackageProjectUrl>https://github.com/apache/fory</PackageProjectUrl>
+ <RepositoryUrl>https://github.com/apache/fory</RepositoryUrl>
+ <RepositoryType>git</RepositoryType>
+
<PackageTags>apache;fory;serialization;binary;cross-language;source-generator;dotnet</PackageTags>
+ <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
+ <PublishRepositoryUrl>true</PublishRepositoryUrl>
+ <IncludeSymbols>true</IncludeSymbols>
+ <SymbolPackageFormat>snupkg</SymbolPackageFormat>
+ </PropertyGroup>
+</Project>
diff --git a/csharp/README.md b/csharp/README.md
index d419341ce..42050d00e 100644
--- a/csharp/README.md
+++ b/csharp/README.md
@@ -25,7 +25,15 @@ The C# implementation provides high-performance object graph
serialization for .
### Add Apache Fory™ C\#
-From this repository, reference the library project:
+From NuGet, reference the single `Apache.Fory` package. It includes the
runtime plus the source generator for `[ForyObject]` types.
+
+```xml
+<ItemGroup>
+ <PackageReference Include="Apache.Fory" Version="0.1.0" />
+</ItemGroup>
+```
+
+For local development against this repository, reference the runtime project
and generator project directly:
```xml
<ItemGroup>
@@ -215,7 +223,7 @@ Fory fory = Fory.Builder()
fory.Register<Person>(100); // same ID on other language peers
```
-See [xlang guide](../docs/guide/xlang/index.md) for mapping details.
+See [xlang guide](https://fory.apache.org/docs/guide/xlang/) for mapping
details.
## Architecture
@@ -240,7 +248,7 @@ csharp/
└── Fory.XlangPeer/
```
-## Building and Testing
+## Building, Testing, and Publishing
Run from the `csharp` directory:
@@ -250,10 +258,13 @@ dotnet build Fory.sln -c Release
# Run tests
dotnet test Fory.sln -c Release
+
+# Publish to nuget.org after bumping <Version> in Directory.Build.props
+NUGET_API_KEY=... ../ci/publish-nuget.sh
```
## Documentation
-- [C# guide index](../docs/guide/csharp/index.md)
-- [Cross-language serialization
spec](../docs/specification/xlang_serialization_spec.md)
-- [Cross-language type mapping](../docs/specification/xlang_type_mapping.md)
+- [C# guide index](https://fory.apache.org/docs/guide/csharp/)
+- [Cross-language serialization
spec](https://fory.apache.org/docs/specification/xlang_serialization_spec/)
+- [Cross-language type
mapping](https://fory.apache.org/docs/specification/xlang_type_mapping/)
diff --git a/csharp/src/Fory.Generator/Fory.Generator.csproj
b/csharp/src/Fory.Generator/Fory.Generator.csproj
index 265d94481..0a920c5eb 100644
--- a/csharp/src/Fory.Generator/Fory.Generator.csproj
+++ b/csharp/src/Fory.Generator/Fory.Generator.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>12.0</LangVersion>
@@ -7,6 +7,7 @@
<IsRoslynComponent>true</IsRoslynComponent>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<IncludeBuildOutput>false</IncludeBuildOutput>
+ <IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
diff --git a/csharp/src/Fory/Fory.csproj b/csharp/src/Fory/Fory.csproj
index 2082c7f5e..006b2caab 100644
--- a/csharp/src/Fory/Fory.csproj
+++ b/csharp/src/Fory/Fory.csproj
@@ -1,8 +1,27 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
+ <PackageId>Apache.Fory</PackageId>
+ <PackageReadmeFile>README.md</PackageReadmeFile>
+
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);PackForyGenerator</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\Fory.Generator\Fory.Generator.csproj"
OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="all" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="..\..\README.md" Pack="true" PackagePath="/" />
+ </ItemGroup>
+
+ <Target Name="PackForyGenerator" DependsOnTargets="ResolveReferences">
+ <ItemGroup>
+ <TfmSpecificPackageFile Include="@(Analyzer)"
Condition="'%(Analyzer.Filename)%(Analyzer.Extension)' == 'Fory.Generator.dll'">
+ <PackagePath>analyzers/dotnet/cs/</PackagePath>
+ </TfmSpecificPackageFile>
+ </ItemGroup>
+ </Target>
</Project>
diff --git a/csharp/tests/Fory.XlangPeer/Fory.XlangPeer.csproj
b/csharp/tests/Fory.XlangPeer/Fory.XlangPeer.csproj
index 8c9263010..b5a039459 100644
--- a/csharp/tests/Fory.XlangPeer/Fory.XlangPeer.csproj
+++ b/csharp/tests/Fory.XlangPeer/Fory.XlangPeer.csproj
@@ -1,10 +1,11 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
+ <IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
diff --git a/docs/guide/csharp/index.md b/docs/guide/csharp/index.md
index b18e414e2..68642df53 100644
--- a/docs/guide/csharp/index.md
+++ b/docs/guide/csharp/index.md
@@ -37,6 +37,16 @@ Apache Fory™ C# is a high-performance, cross-language
serialization runtime fo
- .NET SDK 8.0+
- C# language version 12+
+### Install from NuGet
+
+Reference the single `Apache.Fory` package. It includes the runtime and the
source generator for `[ForyObject]` types.
+
+```xml
+<ItemGroup>
+ <PackageReference Include="Apache.Fory" Version="0.1.0" />
+</ItemGroup>
+```
+
### Basic Example
```csharp
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]