Combining DLLs Into One Published File

Tell me Microsoft, what's the point of having a checkbox that says "produce single file" if it doesn't produce a single file?

Combining DLLs Into One Published File

Setup

So I like to compile my C# script files to a single executable with no external libraries showing. I will go through the rigamarole to publish it and still get the "Microsoft.Data.SqlClient.SNI.dll" in my publish folder. And if you try to just take the executable, it just isn't going to run. Tell me Microsoft, what's the point of having a checkbox that says "produce single file" if it doesn't produce a single file?

The Fix

In Visual Studio, double click the name of your application (which is actually the YourProjectName.csproj file).

In the top property group section, add (it can be on one line, this is broken for clarity):

<IncludeNativeLibrariesForSelfExtract>
true
</IncludeNativeLibrariesForSelfExtract>

That's it! Save, commit, republish. If you empty the folder before republishing you should see the dll not come back or notice that the exe file is slightly larger.