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. |
|
I personally think that the native libraries should each have their own packages and that it should be the Discord Bot creator's responsibility to install the native packages themselves when using NAOT. That way those who don't need the native libraries at all (don't use the voice implementation) can continue to get by without the native library packages. |
Co-authored-by: Kuba_Z2 <77853483+KubaZ2@users.noreply.github.com>
- Fix NetCord.Natives.targets comment typo: 'comes' -> 'come' - Normalize Importance='High' to 'high' in NetCord.Natives.csproj - Remove stale commented-out PackageReference in NativeAotApp.csproj - Update Resources/NuGet/README.md to link to docs for full package list - Add 'natives' devShell to flake.nix with autoconf/automake/libtool - Replace macOS brew step with Nix in build-natives.yml; split Build step for Windows/non-Windows - Pin all GitHub Actions by commit hash in build-natives.yml - Rename build-publish-natives.yml -> build-and-publish-natives.yml; pin download-artifact hash; fix self-reference in paths trigger Agent-Logs-Url: https://github.com/ha-ves/NetCord/sessions/f6e9307c-fd0a-40c8-b3a8-e0484782c21e Co-authored-by: ha-ves <20160532+ha-ves@users.noreply.github.com>
@AraHaan, I am not sure what you mean here. The native packages are completely separate and they are not referenced by NetCord's core package. So it is the creator's responsibility to install the native packages. Not sure what NAOT has to do with it though. |
* Implement resolved PR NetCordDev#257 review comments - Fix NetCord.Natives.targets comment typo: 'comes' -> 'come' - Normalize Importance='High' to 'high' in NetCord.Natives.csproj - Remove stale commented-out PackageReference in NativeAotApp.csproj - Update Resources/NuGet/README.md to link to docs for full package list - Add 'natives' devShell to flake.nix with autoconf/automake/libtool - Replace macOS brew step with Nix in build-natives.yml; split Build step for Windows/non-Windows - Pin all GitHub Actions by commit hash in build-natives.yml - Rename build-publish-natives.yml -> build-and-publish-natives.yml; pin download-artifact hash; fix self-reference in paths trigger Agent-Logs-Url: https://github.com/ha-ves/NetCord/sessions/f6e9307c-fd0a-40c8-b3a8-e0484782c21e Co-authored-by: ha-ves <20160532+ha-ves@users.noreply.github.com> * fix: address natives README link and reflection method visibility Agent-Logs-Url: https://github.com/ha-ves/NetCord/sessions/e686bf59-4e1e-4ec5-82f8-cc6b3ef93656 Co-authored-by: ha-ves <20160532+ha-ves@users.noreply.github.com> * README: add period to NetCord.Natives table description Agent-Logs-Url: https://github.com/ha-ves/NetCord/sessions/0553c8bd-a710-4a4d-a8a8-deb3dc917faa Co-authored-by: ha-ves <20160532+ha-ves@users.noreply.github.com> * Deduplicate native build workflow step and remove MSBuild XML schema namespaces Agent-Logs-Url: https://github.com/ha-ves/NetCord/sessions/a0011395-8ab0-458e-a04e-8152069b7880 Co-authored-by: ha-ves <20160532+ha-ves@users.noreply.github.com> * Fix README NetCord.Natives description punctuation Agent-Logs-Url: https://github.com/ha-ves/NetCord/sessions/a0011395-8ab0-458e-a04e-8152069b7880 Co-authored-by: ha-ves <20160532+ha-ves@users.noreply.github.com> * Revert prior README tweak and set NetCord.Natives row text as requested Agent-Logs-Url: https://github.com/ha-ves/NetCord/sessions/52fb7ee0-c97d-452c-9d94-1eec13cd17ee Co-authored-by: ha-ves <20160532+ha-ves@users.noreply.github.com> * Set README NetCord.Natives row to exact requested text Agent-Logs-Url: https://github.com/ha-ves/NetCord/sessions/5f1c09c3-27c2-48af-872c-0ae465ec420b Co-authored-by: ha-ves <20160532+ha-ves@users.noreply.github.com> * Update README natives row, native dependencies docs, and test configs - Update all README.md files with new NetCord.Natives.<RuntimeId> row format - Replace size column with NuGet package badges in native dependencies table - Clarify libsodium description regarding voice server encryption requirements - Update NativeAotApp.csproj: change DirectPInvoke to directly include libraries - Remove CentrallyManagedPackage false and NoWarn settings from NativeAotApp.csproj - Remove stray -bl argument from NativesBuildTests.cs GetRunCmd Agent-Logs-Url: https://github.com/ha-ves/NetCord/sessions/e244793a-3f65-4653-8019-ee2d5151b0c1 Co-authored-by: ha-ves <20160532+ha-ves@users.noreply.github.com> * Improve libsodium documentation with clearer explanation of encryption fallback scenarios Agent-Logs-Url: https://github.com/ha-ves/NetCord/sessions/2a7fe8b8-026b-4918-8d18-9356084ad340 Co-authored-by: ha-ves <20160532+ha-ves@users.noreply.github.com> * Fix README for NetCord.Natives * fix readme in nuget --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ha-ves <20160532+ha-ves@users.noreply.github.com> Co-authored-by: Haves Irfan <haves.vansyah@gmail.com>
4ef9f24 to
53535fd
Compare
53535fd to
e62276d
Compare
as it causes more issues than it solves (build tools & dependency pinning, which should already be handled by vcpkg). We can revisit this in the future if we find a better way to use nix for this purpose. * re-order workflow properties to be more logical and easier to read. This reverts commit e62276d.
bbc14a2 to
1a02cbd
Compare
|
@KubaZ2 I can't get nix to work for the workflow ... We'll have to just use vcpkg for now, |
What exactly was failing? |
workflow run available here -> https://github.com/ha-ves/NetCord/actions/runs/26461243098 |
Seems to be a code or a compiler issue |
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>