In my attempts to compile a single-file binary that leverages Microsoft.Data.Sqlite, I am consistently left with two files that are both required for the application to work.
{ProjectName}.exe
e_sqlite3.dll
Is it possible to include the e_sqlite3.dll
into the exe?
It appears that System.Data.Sqlite exhibits the same behaviour, but instead a file called
SQLite.Interop.dll
.
Sample code
Note: I realize there is no actual interop with SQLite happening, this code is purely meant to demonstrate the compilation.
ProjectName.fsproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.Sqlite" version="7.*" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
</Project>
Program.fs
module ProjectName.Program
open System
[<EntryPoint>]
let main (argv : string[]) =
printfn "Hello world"
0
Compiling the project as follows:
dotnet publish .\ProjectName.fsproj -c Release