feat: add local NuGet development workflow

Add a local NuGet feed configuration, a Directory.Build.props
template for Godot users, and automate source generator bundling
into the NuGet package.
This commit is contained in:
hypercross 2026-07-19 00:30:36 +08:00
parent 1da0ca30d3
commit 5594515a53
4 changed files with 47 additions and 0 deletions

1
.gitignore vendored
View File

@ -15,6 +15,7 @@ x86/
!**/[Pp]ackages/build/
*.nuget.props
*.nuget.targets
nupkgs/
# IDE
.vs/

View File

@ -0,0 +1,21 @@
<!--
Directory.Build.props for Godot C# projects consuming OECS.
Godot regenerates .csproj files on certain editor actions, which can
wipe custom <ItemGroup> entries. This file is never touched by Godot.
Placement: put this file in the root of your Godot project (next to
the .sln file), or in any parent directory.
You also need a nuget.config next to your .sln with the local feed:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="local-oecs" value="path/to/oecs-sharp/nupkgs" />
</packageSources>
</configuration>
-->
<Project>
<ItemGroup>
<PackageReference Include="OECS" Version="0.1.*" />
</ItemGroup>
</Project>

9
nuget.config Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!-- Local feed for OECS development builds.
Run `dotnet pack src/OECS/OECS.csproj -c Release -o ./nupkgs`
to produce the package. -->
<add key="local-oecs" value="./nupkgs" />
</packageSources>
</configuration>

View File

@ -23,4 +23,20 @@
<PackageReference Include="R3" Version="1.2.9" />
</ItemGroup>
<!-- Bundle the source generator into the NuGet package as an analyzer.
Consumers get compile-time component discovery automatically. -->
<ItemGroup>
<None Include="..\OECS.SourceGen\bin\$(Configuration)\netstandard2.0\OECS.SourceGen.dll"
Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
</ItemGroup>
<!-- Ensure the source generator is built before packing.
Skipped when NoBuild property is set to true. -->
<Target Name="BuildSourceGenerator" BeforeTargets="GenerateNuspec"
Condition="'$(NoBuild)' != 'true'">
<MSBuild Projects="..\OECS.SourceGen\OECS.SourceGen.csproj"
Targets="Build"
Properties="Configuration=$(Configuration)" />
</Target>
</Project>