Skip to content

Commit 2d6bd57

Browse files
Merged Pull Request '#722 fix/runtime-identifier->main: Prevent wrong-platform native DLL from overriding Linux publish output'
* fix: use RID-based native asset selection for hash engine package * fix: suppress SDK-project native DLL copy in .targets; fix direct-pack paths in .csproj
1 parent 6b55565 commit 2d6bd57

File tree

2 files changed

+50
-31
lines changed

2 files changed

+50
-31
lines changed

FiftyOne.DeviceDetection.Hash.Engine.OnPremise/FiftyOne.DeviceDetection.Hash.Engine.OnPremise.csproj

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@
4747
<BuildType>Release</BuildType>
4848
</PropertyGroup>
4949

50+
<PropertyGroup>
51+
<_DirectPackRuntimePlatform Condition="'$(Platform)' == 'x64'">x64</_DirectPackRuntimePlatform>
52+
<_DirectPackRuntimePlatform Condition="'$(Platform)' == 'x86'">x86</_DirectPackRuntimePlatform>
53+
<_DirectPackRuntimePlatform Condition="'$(Platform)' == 'ARM64'">arm64</_DirectPackRuntimePlatform>
54+
55+
<_DirectPackRuntimeIdentifier Condition="$([MSBuild]::IsOsPlatform('Windows')) AND '$(_DirectPackRuntimePlatform)' != ''">win-$(_DirectPackRuntimePlatform)</_DirectPackRuntimeIdentifier>
56+
<_DirectPackRuntimeIdentifier Condition="$([MSBuild]::IsOsPlatform('Linux')) AND '$(_DirectPackRuntimePlatform)' != ''">linux-$(_DirectPackRuntimePlatform)</_DirectPackRuntimeIdentifier>
57+
<_DirectPackRuntimeIdentifier Condition="$([MSBuild]::IsOsPlatform('OSX')) AND '$(_DirectPackRuntimePlatform)' != ''">osx-$(_DirectPackRuntimePlatform)</_DirectPackRuntimeIdentifier>
58+
</PropertyGroup>
59+
5060
<ItemGroup>
5161
<Compile Remove="build\**" />
5262
<Compile Remove="device-detection-cxx\**" />
@@ -132,20 +142,29 @@
132142
</_PackageFiles>
133143

134144
<!-- Direct pack -->
135-
<!-- Copy the Windows x86/x64 native DLL -->
136-
<_PackageFiles Include="$(OutputPath)\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll" Condition="$([MSBuild]::IsOsPlatform('Windows')) AND !$(BuiltOnCI)">
145+
<_PackageFiles Include="..\windows\x64\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll" Condition="!$(BuiltOnCI) and Exists('..\windows\x64\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll')">
146+
<BuildAction>None</BuildAction>
147+
<PackagePath>runtimes\win-x64\native</PackagePath>
148+
</_PackageFiles>
149+
<_PackageFiles Include="..\windows\x86\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll" Condition="!$(BuiltOnCI) and Exists('..\windows\x86\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll')">
150+
<BuildAction>None</BuildAction>
151+
<PackagePath>runtimes\win-x86\native</PackagePath>
152+
</_PackageFiles>
153+
<_PackageFiles Include="..\linux\x64\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll" Condition="!$(BuiltOnCI) and Exists('..\linux\x64\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll')">
154+
<BuildAction>None</BuildAction>
155+
<PackagePath>runtimes\linux-x64\native</PackagePath>
156+
</_PackageFiles>
157+
<_PackageFiles Include="..\linux\arm64\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll" Condition="!$(BuiltOnCI) and Exists('..\linux\arm64\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll')">
137158
<BuildAction>None</BuildAction>
138-
<PackagePath>runtimes\win-x$(Platform)\native</PackagePath>
159+
<PackagePath>runtimes\linux-arm64\native</PackagePath>
139160
</_PackageFiles>
140-
<!-- Copy the Linux x86/x64 native DLL -->
141-
<_PackageFiles Include="$(OutputPath)\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll" Condition="$([MSBuild]::IsOsPlatform('Linux')) AND !$(BuiltOnCI)">
161+
<_PackageFiles Include="..\macos\x64\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll" Condition="!$(BuiltOnCI) and Exists('..\macos\x64\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll')">
142162
<BuildAction>None</BuildAction>
143-
<PackagePath>runtimes\linux-$(Platform)\native</PackagePath>
163+
<PackagePath>runtimes\osx-x64\native</PackagePath>
144164
</_PackageFiles>
145-
<!-- Copy the Mac x64/arm64 native DLL -->
146-
<_PackageFiles Include="$(OutputPath)\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll" Condition="$([MSBuild]::IsOsPlatform('OSX')) AND !$(BuiltOnCI)">
165+
<_PackageFiles Include="..\macos\arm64\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll" Condition="!$(BuiltOnCI) and Exists('..\macos\arm64\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll')">
147166
<BuildAction>None</BuildAction>
148-
<PackagePath>runtimes\osx-$(Platform)\native</PackagePath>
167+
<PackagePath>runtimes\osx-arm64\native</PackagePath>
149168
</_PackageFiles>
150169
</ItemGroup>
151170
<ItemGroup>
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33

4-
<!-- Ensure that for Framework projects the correct DLL is copied to the build directory -->
5-
6-
<!-- If the build is for AnyCPU, then assume x64 and copy to the root of the bin directory -->
7-
<ItemGroup Condition=" '$(Platform)' == 'AnyCPU' ">
8-
<None Include="$(MSBuildThisFileDirectory)..\runtimes\win-x64\native\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll">
9-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
10-
<Link>FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll</Link>
11-
</None>
12-
</ItemGroup>
13-
<!-- If the build is for x64, copy to the root of the bin directory -->
14-
<ItemGroup Condition=" '$(Platform)' == 'x64' ">
15-
<None Include="$(MSBuildThisFileDirectory)..\runtimes\win-x64\native\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll">
16-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
17-
<Link>FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll</Link>
18-
</None>
19-
</ItemGroup>
20-
<!-- If the build is for x86, copy to the root of the bin directory -->
21-
<ItemGroup Condition=" '$(Platform)' == 'x86' ">
22-
<None Include="$(MSBuildThisFileDirectory)..\runtimes\win-x86\native\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll">
4+
<PropertyGroup>
5+
<_FiftyOneNativeAssetName>FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll</_FiftyOneNativeAssetName>
6+
7+
<!-- Prefer the runtime identifier when one is available. -->
8+
<_FiftyOneNativeRuntime Condition="'$(RuntimeIdentifier)' != ''">$(RuntimeIdentifier)</_FiftyOneNativeRuntime>
9+
10+
<!-- Fall back to the legacy Windows platform mapping when no RID is set. -->
11+
<_FiftyOneNativeRuntime Condition="'$(_FiftyOneNativeRuntime)' == '' and '$(Platform)' == 'x86'">win-x86</_FiftyOneNativeRuntime>
12+
<_FiftyOneNativeRuntime Condition="'$(_FiftyOneNativeRuntime)' == '' and ('$(Platform)' == 'x64' or '$(Platform)' == 'AnyCPU' or '$(Platform)' == '')">win-x64</_FiftyOneNativeRuntime>
13+
14+
<_FiftyOneNativeAssetPath Condition="'$(_FiftyOneNativeRuntime)' != ''">$(MSBuildThisFileDirectory)..\runtimes\$(_FiftyOneNativeRuntime)\native\$(_FiftyOneNativeAssetName)</_FiftyOneNativeAssetPath>
15+
</PropertyGroup>
16+
17+
<!-- SDK-style projects (.NET Core / .NET 5+) resolve native assets automatically via the
18+
runtimes/ folder in the NuGet package — no manual copy needed, and attempting one
19+
would overwrite the correctly-resolved platform binary with a wrong one.
20+
Only activate this copy for legacy .NET Framework consumers. -->
21+
<ItemGroup Condition="'$(_FiftyOneNativeAssetPath)' != '' and Exists('$(_FiftyOneNativeAssetPath)') and '$(UsingMicrosoftNETSdk)' != 'true'">
22+
<None Include="$(_FiftyOneNativeAssetPath)">
2323
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
24-
<Link>FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll</Link>
24+
<Link>$(_FiftyOneNativeAssetName)</Link>
2525
</None>
2626
</ItemGroup>
27-
</Project>
27+
</Project>

0 commit comments

Comments
 (0)