Provide prebuilt native libraries by NuGet Packages.#257
Conversation
1c05c69 to
6565a35
Compare
|
The documentation preview is available at https://preview.netcord.dev/257. |
|
I feel like the best option is to do something like: |
* put into nuget package
* Add native ports for libdave and mlspp * Update build workflows for native packaging * Add local targets and CI helpers for natives * Update README
- GitHub Actions tag triggers, NuGet publish job - NativesHelper, NativeLibraryVersionAttribute - vcpkg integration, static linking - zstd support - native library tests, import checks - Native AOT test app - NetCordNativesDir assembly metadata
* Add MSVC builtin add overflow patch for libdave * Add vcpkg-non-windows.targets for cross-platform support * Update libdave and mlspp portfiles with build fixes * Update build-natives workflow and vcpkg.json versions * Fix vcpkg dependency resolution for multi-platform builds
* Add dynamic library exclusion for AOT builds * Add NativeAotApp test project
* natives conditionals fix * fix nativeaot test structure * add natives tests to build workflow
- add reusable vcpkg setup - pack per-RID native nupkgs - streamline NativeAOT test logging - tighten native linking targets
66a1e8d to
ee00a64
Compare
|
@AraHaan by default CI workflow will provide per-RID packages now. But by .csproj design it will also work If anyone for some reason still needs to package all in one. |
KubaZ2
left a comment
There was a problem hiding this comment.
I haven't went through all the MSBuild stuff. I kind of hate that it takes so much and I am afraid it may require changes when new versions of binaries get released. I guess there is no better way to handle that? I think most binaries just require a single make or 2 cmake commands to build, but I think most of the MSBuild stuff is just for copying the binaries in the correct place and licensing?
Vcpkg is the least time-consuming dependency manager, it can build and put it all together in a convenient path. The previous version of this PR was just using CMake, but it won't get the dependencies for your NativeAOT. you can refer to this when there's new version:
|
* Skip testing for OSX due to dyld limitation * Clean up natives packaging * Docs updates for prebuilt natives
|
@KubaZ2, there are some limitations from comments, but I think this PR is ready. |
Summary
Continues from #245. Implements CI-driven distribution of prebuilt native binary dependencies.
Download size: ~112 MBExtracted size: ~429 MBNeed to Follow-Updotnet test Tests/NetCord.Natives.Tests/ -tl:off -clp:NoSummary,Verbosity=normal -v normal -bland then use https://github.com/JanKrivanek/MSBuildStructuredLog
Included in This PR
✓ CI multi-platform native package build and publish
✓ Per-RID targeted package distribution
✓ Direct integration usage
✓ Custom vcpkg overlay ports for libdave and mlspp &
✓ Dependencies pinning
✓ Basic Unit & Integration tests
Overview
This PR provides prebuilt native libraries via NuGet as per-RID packages. Each package bundles:
Packages are published automatically on successful CI builds to the configured NuGet feed.
Structure & Packaging Model
Per-RID Distribution Model:
NetCord.Natives.{win|linux|osx}-{x64|arm64}NetCord.Natives.linux-x64,NetCord.Natives.win-arm64Package Contents (per-RID package):
What Changed
CI Pruning:
Core Build & Packaging
libdave/portfile.cmake— discord/libdave with MSVC ARM64 patchmlspp/portfile.cmake— cisco/mlspp, libdave's dependencyNuGet Package build files
$(RuntimeIdentifier)Accessible MetadataNativesHelper.cs:NativeLibraryVersionAttributefor runtime version discovery of bundled native libsHow to Use
Maintainer Notes:
vcpkgBaseline & Dependency PinningAll native dependencies are pinned to a specific vcpkg baseline (vcpkg.json) to ensure reproducible builds.
When upgrading native library versions:
vcpkg.jsonResource requirements:
Testing
Comprehensive native library validation via Tests/NetCord.Natives.Tests/:
Unit Tests (NativesBuildTests.cs)
Framework: MSTest with method-level parallelization
Target: .NET 10.0
NativeLoaded— Runtime Library ResolutionNativeLibrary.Load()AllLibraryImportsExistInBinary— P/Invoke Symbol Verification[LibraryImport]entry pointsNativeLibrary.TryGetExport()NativeAotStaticLinking— NativeAOT Full Integrationdotnet publish -c Releaseon NativeAotApp with<PublishAot>enabled:win-x64,linux-x64,osx-arm64)<DirectPInvoke>