Skip to content

Prevent wrong-platform native DLL from overriding Linux publish output#722

Merged
Automation51D merged 2 commits intomainfrom
fix/runtime-identifier
Apr 10, 2026
Merged

Prevent wrong-platform native DLL from overriding Linux publish output#722
Automation51D merged 2 commits intomainfrom
fix/runtime-identifier

Conversation

@viktor-shnaider
Copy link
Copy Markdown
Contributor

@viktor-shnaider viktor-shnaider commented Apr 1, 2026

Problem

dotnet publish -r linux-x64 produced a Windows PE32+ DLL instead of a Linux ELF binary.

The package's .targets file used hard-coded <ItemGroup> blocks that always copied runtimes/win-x64/native/ into every SDK project's bin/ output. SDK-style projects don't need this - NuGet resolves the correct runtimes/{rid}/native/ binary automatically at publish time. The forced copy overwrote the correct Linux binary with a Windows one before the publish collector ran.

Changes

.targets two fixes:

  1. Replace three Platform-keyed <ItemGroup> blocks with a single that prefers $(RuntimeIdentifier) and falls back to a Platform → RID mapping.
  2. Add '$(UsingMicrosoftNETSdk)' != 'true' to the <ItemGroup> condition. The manual copy is only needed for legacy .NET Framework consumers; SDK-style projects get native assets resolved automatically, and the copy was actively breaking cross-platform publishing.

.csproj direct-pack - fix broken paths in the !$(BuiltOnCI) pack items:

Reproduce (Linux / WSL)

  mkdir /tmp/repro && cd /tmp/repro
  dotnet new console
  dotnet add package FiftyOne.DeviceDetection.Hash.Engine.OnPremise --version 4.5.62  # pre-fix
  dotnet publish -r linux-x64 -c Release --self-contained false
  file bin/Release/net*/linux-x64/publish/FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll
  # Before fix: PE32+ executable (DLL) (GUI), x86-64  ← wrong
  # After fix:  ELF 64-bit LSB shared object, x86-64  ← correct

@viktor-shnaider viktor-shnaider self-assigned this Apr 1, 2026
@viktor-shnaider viktor-shnaider added the type: bug Something isn't working label Apr 2, 2026
@justadreamer justadreamer removed the request for review from drasmart April 10, 2026 13:20
@Automation51D Automation51D merged commit 2d6bd57 into main Apr 10, 2026
@Automation51D Automation51D deleted the fix/runtime-identifier branch April 10, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants