Skip to content

Fix bftree_garnet.dll NuGet packaging#1963

Merged
tiagonapoli merged 5 commits into
mainfrom
tiagonapoli/fix-bftree-native-packaging
Jul 23, 2026
Merged

Fix bftree_garnet.dll NuGet packaging#1963
tiagonapoli merged 5 commits into
mainfrom
tiagonapoli/fix-bftree-native-packaging

Conversation

@tiagonapoli

@tiagonapoli tiagonapoli commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Problem

Microsoft.Garnet fails to consume on Windows with:

warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible.
Could not load file or assembly 'bftree_garnet.dll' or one of its dependencies.
The module was expected to contain an assembly manifest.

The native Rust library bftree_garnet.dll leaked into the package's lib/<tfm>/ folder,
where NuGet treats every DLL as a managed assembly. Because the native has no assembly
manifest, restore/build of any consumer emits MSB3246.

Root cause

PR #1933 added a fallback to BfTreeInterop.csproj that copies the committed
runtimes/<rid>/native/ binary to the build output root whenever a fresh cargo build
is absent (i.e. no Rust — the packaging build). From the output root the native propagated
through ProjectReference into Garnet.host's output root and was swept into lib/<tfm>
by Garnet.host.csproj's lib\*.dll wildcard.

#1933 added that fallback because, at the time, BfTreeInterop.test referenced only
BfTreeInterop and could not otherwise find the native without Rust. That is no longer
true (see below), so the fallback is pure liability now.

Fix

Structured as a clean, auditable revert-and-reapply:

  1. Revert Fix RI.DEL failures from stale BfTree native binaries #1933 in full — removes the output-root fallback (the leak).
  2. Re-apply the non-leak parts of Fix RI.DEL failures from stale BfTree native binaries #1933 — refresh the committed win-x64/linux-x64
    native binaries to match the current Rust FFI (bftree_delete returns an int status;
    fixes RangeIndex RI.DEL: invalid arguments), and drop the CI step that built the
    cdylib with cargo. The output-root fallback is deliberately NOT reintroduced.

Net change vs main: the 13-line output-root fallback removed from BfTreeInterop.csproj.
(The revert/re-apply of the CI step and binaries nets to zero.)

Why no resolver / no output-root copy is needed

bftree_garnet is a ProjectReference native staged only under runtimes/<rid>/native/.
A native library is loadable when its directory is on the NATIVE_DLL_SEARCH_DIRECTORIES
list, which the host builds from native runtimeTargets entries in the app's deps.json.
ProjectReference natives get no such entry — but NuGet-packaged natives (diskann, lua54)
do, and they register runtimes/win-x64/native/ and runtimes/linux-x64/native/. Since
bftree_garnet is staged in that same directory, it loads for free ("free-rides").

Since #1939, BfTreeInterop.test references Garnet.test (→ GarnetServer → diskann/lua54),
so its deps.json registers runtimes/<rid>/native/ and it free-rides exactly like every
other test host (e.g. Garnet.test.rangeindex). No output-root copy and no custom
DllImportResolver are required.

Verification

Windows (the actual bug), Release pack with no Rust:

package native in lib/ native in runtimes/
main lib/net8.0/bftree_garnet.dll, lib/net10.0/bftree_garnet.dll (leak) present
this PR none (fixed) runtimes/{win-x64,linux-x64}/native/

Clean-room Linux Docker container (dotnet/sdk:10.0, no Rust toolchain, cloned fresh
from a git bundle — no host files copied):

  • Full Garnet.slnx build (Release): 0 warnings, 0 errors, no MSB3246.
  • BfTreeInterop.test: 46/46 pass with no output-root copy and no resolver — proving
    the diskann free-ride is sufficient.
  • Garnet.test.rangeindex: 63/63 pass.

Also verified on Windows: full solution build plus BfTreeInterop.test 46/46 and
Garnet.test.rangeindex 63/63 without Rust.

@tiagonapoli
tiagonapoli force-pushed the tiagonapoli/fix-bftree-native-packaging branch 2 times, most recently from 216896c to d29798e Compare July 21, 2026 22:45
@tiagonapoli tiagonapoli changed the title Fix MSB3246: pack native bftree_garnet.dll under runtimes/ not lib/ Fix pack for bftree_garnet.dll Jul 21, 2026
@tiagonapoli
tiagonapoli force-pushed the tiagonapoli/fix-bftree-native-packaging branch from d29798e to bc66f03 Compare July 21, 2026 22:47
@tiagonapoli
tiagonapoli marked this pull request as ready for review July 21, 2026 22:52
Copilot AI review requested due to automatic review settings July 21, 2026 22:52
@tiagonapoli tiagonapoli changed the title Fix pack for bftree_garnet.dll Fix pack for bftree_garnet.dll and bump version to 2.0.1-beta.10 Jul 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes NuGet packaging for the new Bf-Tree range index native binary by ensuring bftree_garnet.dll is not placed under lib/<tfm>/ (where NuGet/MSBuild treats it as a managed reference), and bumps the package version to ship the corrected layout.

Changes:

  • Bump VersionPrefix from 2.0.1-beta.9 to 2.0.1-beta.10.
  • Update Garnet.host.csproj pack globs to exclude the native bftree_garnet.dll from lib/net8.0 and lib/net10.0, while continuing to pack native assets via runtimes/**.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Version.props Bumps version to 2.0.1-beta.10 to publish the packaging fix.
libs/host/Garnet.host.csproj Excludes bftree_garnet.dll from lib/<tfm> pack items so consumers don’t attempt to load it as a managed assembly; leaves runtime-native packing intact.

@tiagonapoli
tiagonapoli force-pushed the tiagonapoli/fix-bftree-native-packaging branch from bc66f03 to f979d8b Compare July 22, 2026 03:54
@tiagonapoli tiagonapoli changed the title Fix pack for bftree_garnet.dll and bump version to 2.0.1-beta.10 Fix bftree_garnet.dll NuGet packaging leak (MSB3246) at the source Jul 22, 2026
@tiagonapoli tiagonapoli changed the title Fix bftree_garnet.dll NuGet packaging leak (MSB3246) at the source Fix bftree_garnet.dll NuGet packaging Jul 22, 2026
Tiago Napoli and others added 2 commits July 21, 2026 21:04
Reintroduces the parts of #1933 that were unrelated to the packaging leak,
which the preceding full revert removed:
- Refresh the committed win-x64 and linux-x64 native binaries to match the
  current Rust FFI (bftree_delete returns an int status), fixing RangeIndex
  RI.DEL "invalid arguments" failures.
- Drop the CI step that built the cdylib with cargo for BfTreeInterop.test;
  CI consumes the committed binaries.

The output-root fallback ItemGroup from #1933 (the packaging leak source) is
deliberately NOT reintroduced.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 714ad8a9-ef8b-4d41-8085-982b4cf952b9
@tiagonapoli
tiagonapoli force-pushed the tiagonapoli/fix-bftree-native-packaging branch from f979d8b to ff37813 Compare July 22, 2026 04:17
@tiagonapoli tiagonapoli changed the title Fix bftree_garnet.dll NuGet packaging Fix bftree_garnet.dll NuGet packaging leak (MSB3246) by reverting #1933's output-root fallback Jul 22, 2026
@tiagonapoli tiagonapoli changed the title Fix bftree_garnet.dll NuGet packaging leak (MSB3246) by reverting #1933's output-root fallback Fix bftree_garnet.dll Nuget packaging Jul 22, 2026
@tiagonapoli
tiagonapoli force-pushed the tiagonapoli/fix-bftree-native-packaging branch 2 times, most recently from 8a77ba9 to 5af9e7d Compare July 22, 2026 16:52
@tiagonapoli tiagonapoli changed the title Fix bftree_garnet.dll Nuget packaging Fix bftree_garnet.dll NuGet packaging leak (MSB3246) by reverting #1933's output-root fallback Jul 22, 2026
@tiagonapoli
tiagonapoli force-pushed the tiagonapoli/fix-bftree-native-packaging branch from 5af9e7d to 253533e Compare July 22, 2026 17:13
@tiagonapoli tiagonapoli changed the title Fix bftree_garnet.dll NuGet packaging leak (MSB3246) by reverting #1933's output-root fallback Fix bftree_garnet.dll NuGet packaging leak Jul 22, 2026
@tiagonapoli tiagonapoli changed the title Fix bftree_garnet.dll NuGet packaging leak Fix bftree_garnet.dll NuGet packaging Jul 23, 2026
@tiagonapoli
tiagonapoli merged commit c89e68d into main Jul 23, 2026
316 of 317 checks passed
@tiagonapoli
tiagonapoli deleted the tiagonapoli/fix-bftree-native-packaging branch July 23, 2026 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants