Can't get costura.fody to embed dll into exe

Solution 1:

This can be accomplished without any additional package. Since NET 5 you have to set two options.

<PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
    <!-- To publish just a single *.exe file -->
    <PublishSingleFile>true</PublishSingleFile>
    <!-- Specify for which runtime you want to publish -->
    <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
    <!-- Since NET 5 specify this if you want to also pack all external *.dll to your file -->
    <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
    <!-- Add trimming for a smaller file size if possible--->
    <PublishTrimmed>true</PublishTrimmed>
</PropertyGroup>

With setting IncludeNativeLibrariesForSelfExtract to false

enter image description here

With setting IncludeNativeLibrariesForSelfExtract to true

enter image description here

Documentation for publish single file

Documentation for trimming