[ACCEPTED]-How do I get rid of SNI.dll when publishing as a "single file" in Visual Studio 2019?-publish

Accepted answer
Score: 14

I faced the same problem as yours and found 7 the solution here. It turns out that native 6 libraries are not bundled in the single 5 file executable by default. You must set 4 the flag IncludeNativeLibrariesForSelfExtract to true to get this behavior.

You might 3 also want to check your .deps.json file 2 (from your build folder) to see how you 1 got this dependency in the first place.

Score: 2

As Simon V. stated, you can work around 23 this issue by adding IncludeNativeLibrariesForSelfExtract to your project file 22 and setting it to true.

tl;dr Dotnet's Windows 21 runtime depends on sni.dll.

One day I hope 20 to find out why it's there at all since 19 I can't even find a reference to System.Data 18 anywhere in my entire solution, but you've 17 been a big help. Cheers

-- HumanBean

You might also 16 want to check your .deps.json file (from 15 your build folder) to see how you got this 14 dependency in the first place.

-- Simon V.

Given a 13 publish directory path of "bin\Release\net6.0-windows\win-x86\publish", check 12 in the parent directory (win-x86, the RID) for 11 a file named "$(AssemblyName).deps.json".

Search 10 that folder for a dependency's assembly 9 name or file name.

In my project's dependencies 8 file, "sni.dll" is referenced 7 by the following snippet:

  "runtimeTarget": {
    "name": ".NETCoreApp,Version=v6.0/win-x86",
    "signature": ""
  "compilationOptions": {},
  "targets": {
    ".NETCoreApp,Version=v6.0": {},
    ".NETCoreApp,Version=v6.0/win-x86": {
      "runtime.win-x86.runtime.native.System.Data.SqlClient.sni/4.4.0": {
        "native": {
          "runtimes/win-x86/native/sni.dll": {
            "fileVersion": "4.6.25512.1"

For the sake of 6 further investigation, I'll include additional 5 information.

All instances of sni.dll on 4 my computers share the following attributes...

  • ProductVersion: 4.6.25512.01 built by: dlab-DDVSOWINAGE016. Commit Hash: d0d5c7b49271cadb6d97de26d8e623e98abdc8db
  • ProductName: Microsoft® .NET Framework
  • Modified Date: 7/12/2017.

I 3 wonder why the .NET 5+ runtimes depend on 2 what appears to be a component of the .NET 1 Framework.

More Related questions