Skip to content

Commit 42099ce

Browse files
committed
Include staged macOS native binary when packing
1 parent b928b96 commit 42099ce

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/MLXSharp/MLXSharp.csproj

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
</ItemGroup>
1616

1717
<PropertyGroup>
18-
<MLXSharpMacNativeBinary Condition="'$(MLXSharpMacNativeBinary)' == ''">$(MSBuildProjectDirectory)..\..\native\build\libmlxsharp.dylib</MLXSharpMacNativeBinary>
19-
<MLXSharpMacNativeDestination>..\MLXSharp.Native\runtimes\osx-arm64\native\libmlxsharp.dylib</MLXSharpMacNativeDestination>
18+
<MLXSharpProjectDirectory>$(MSBuildThisFileDirectory)</MLXSharpProjectDirectory>
19+
<MLXSharpNativeRuntimeRoot>$(MLXSharpProjectDirectory)..\MLXSharp.Native\runtimes</MLXSharpNativeRuntimeRoot>
20+
<MLXSharpMacNativeBinary Condition="'$(MLXSharpMacNativeBinary)' == ''">$(MLXSharpProjectDirectory)..\..\native\build\libmlxsharp.dylib</MLXSharpMacNativeBinary>
21+
<MLXSharpMacNativeDestination>$(MLXSharpNativeRuntimeRoot)\osx-arm64\native\libmlxsharp.dylib</MLXSharpMacNativeDestination>
22+
<MLXSharpMacNativeDestinationDir>$([System.IO.Path]::GetDirectoryName('$(MLXSharpMacNativeDestination)'))</MLXSharpMacNativeDestinationDir>
2023
<MLXSharpSkipMacNativeValidation Condition="'$(MLXSharpSkipMacNativeValidation)' == ''">false</MLXSharpSkipMacNativeValidation>
2124
</PropertyGroup>
2225

@@ -28,11 +31,24 @@
2831
Condition="Exists('$(MLXSharpMacNativeBinary)')" />
2932
</ItemGroup>
3033

34+
<MakeDir Directories="$(MLXSharpMacNativeDestinationDir)"
35+
Condition="'$(MLXSharpMacNativeDestinationDir)' != ''" />
36+
3137
<Copy SourceFiles="@(_MacNativeSource)"
3238
DestinationFiles="$(MLXSharpMacNativeDestination)"
3339
SkipUnchangedFiles="true"
3440
Condition="'@(_MacNativeSource)' != ''" />
3541

42+
<ItemGroup>
43+
<None Include="$(MLXSharpMacNativeDestination)"
44+
Condition="Exists('$(MLXSharpMacNativeDestination)')">
45+
<Pack>true</Pack>
46+
<PackagePath>runtimes/osx-arm64/native/%(Filename)%(Extension)</PackagePath>
47+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
48+
<Link>runtimes\osx-arm64\native\%(Filename)%(Extension)</Link>
49+
</None>
50+
</ItemGroup>
51+
3652
<Error Condition="'$(MLXSharpSkipMacNativeValidation)' != 'true' and !Exists('$(MLXSharpMacNativeDestination)')"
3753
Text="libmlxsharp.dylib is missing. Build the native library or supply MLXSharpMacNativeBinary before packing." />
3854
</Target>

0 commit comments

Comments
 (0)