Last active
June 8, 2024 10:17
-
-
Save 0xced/3c38e6d7c5dfd16536ba9412cb79ba64 to your computer and use it in GitHub Desktop.
Embed native e_sqlite3.dll or SQLite.Interop.dll with Costura without having to manually copy any dll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Useful when bundling an app using Microsoft.EntityFrameworkCore.Sqlite, which depends on SQLitePCLRaw.bundle_green, which depends on SQLitePCLRaw.lib.e_sqlite3.v110_xp (having native Windows dlls) --> | |
<ItemGroup> | |
<EmbeddedResource Include="$(NugetPackageRoot)\sqlitepclraw.lib.e_sqlite3.v110_xp\1.1.13\runtimes\win-x86\native\e_sqlite3.dll"> | |
<Link>costura32\e_sqlite3.dll</Link> | |
</EmbeddedResource> | |
<EmbeddedResource Include="$(NugetPackageRoot)\sqlitepclraw.lib.e_sqlite3.v110_xp\1.1.13\runtimes\win-x64\native\e_sqlite3.dll"> | |
<Link>costura64\e_sqlite3.dll</Link> | |
</EmbeddedResource> | |
</ItemGroup> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>net472</TargetFramework> | |
<!-- We don't need to copy SQLite.Interop.dll since they are embedded with Costura (used by %USERPROFILE%\.nuget\packages\system.data.sqlite.core\{version}\build\net46\System.Data.SQLite.Core.targets) --> | |
<CopySQLiteInteropFiles>false</CopySQLiteInteropFiles> | |
</PropertyGroup> | |
<ItemGroup> | |
<PackageReference Include="Costura.Fody" Version="3.3.3" /> | |
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.111" /> | |
</ItemGroup> | |
<Target Name="EmbedSQLiteInteropFiles" BeforeTargets="ResolveReferences"> | |
<ItemGroup> | |
<!-- Condition on item metadata trick adapted from https://stackoverflow.com/questions/5103026/in-msbuild-can-i-use-the-string-replace-function-on-a-metadata-item/8904902#8904902 --> | |
<EmbeddedResource Include="@(SQLiteInteropFiles)"> | |
<!-- Syntax could be simplified in the future in MSBuild, see [Metadata should support instance methods](https://github.com/microsoft/msbuild/issues/1155) --> | |
<Link Condition="$([MSBuild]::ValueOrDefault('%(Identity)', '').Contains('x86'))">costura32\%(Filename)%(Extension)</Link> | |
<Link Condition="$([MSBuild]::ValueOrDefault('%(Identity)', '').Contains('x64'))">costura64\%(Filename)%(Extension)</Link> | |
</EmbeddedResource> | |
</ItemGroup> | |
</Target> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment