Search code examples
asp.net-corepdb-files.net-5asp.net-core-5.0

Can I safely delete references to .pdb files?


I am using ASP.NET Core 5.0 since it came out a short while ago and I noticed something strange today. I crafted an installer for my software, which automatically filters out each .pdb file that slipped into my release build. A mechanism that never caused problems.

But the new .NET 5.0 runtime seems to have a problem with it, and IIS complained that it could not find the file runtimes/win-x86/native/Microsoft.Data.SqlClient.SNI.pdb.

I wondered why missing debug symbols would be an issue for a release build (or any build) and did some research. I found that the file in question was en entry in MyProject.deps.json

"Microsoft.Data.SqlClient.SNI.runtime/2.0.1": {
    "runtimeTargets": {
      "runtimes/win-arm/native/Microsoft.Data.SqlClient.SNI.dll": {
        "rid": "win-arm",
        "assetType": "native",
        "fileVersion": "2.0.1.0"
      },
      "runtimes/win-arm/native/Microsoft.Data.SqlClient.SNI.pdb": {
        "rid": "win-arm",
        "assetType": "native",
        "fileVersion": "0.0.0.0"
      },
      "runtimes/win-arm64/native/Microsoft.Data.SqlClient.SNI.dll": {
        "rid": "win-arm64",
        "assetType": "native",
        "fileVersion": "2.0.1.0"
      },
      "runtimes/win-arm64/native/Microsoft.Data.SqlClient.SNI.pdb": {
        "rid": "win-arm64",
        "assetType": "native",
        "fileVersion": "0.0.0.0"
      },
      "runtimes/win-x64/native/Microsoft.Data.SqlClient.SNI.dll": {
        "rid": "win-x64",
        "assetType": "native",
        "fileVersion": "2.0.1.0"
      },
      "runtimes/win-x64/native/Microsoft.Data.SqlClient.SNI.pdb": {
        "rid": "win-x64",
        "assetType": "native",
        "fileVersion": "0.0.0.0"
      },
      "runtimes/win-x86/native/Microsoft.Data.SqlClient.SNI.dll": {
        "rid": "win-x86",
        "assetType": "native",
        "fileVersion": "2.0.1.0"
      },
      "runtimes/win-x86/native/Microsoft.Data.SqlClient.SNI.pdb": {
        "rid": "win-x86",
        "assetType": "native",
        "fileVersion": "0.0.0.0"
      }
    }
  },

As you can see, there are 4 .pdb files in there. I tried deleting the one entry that caused the problem, and boom... everything works fine by now. Just adding the .pdb file to the folder also did the trick. So I already solved the practical problem by myself.

My question is: Can I safely delete those entrys from the .deps.json, or might that cause problems? Could this be an error by Microsoft? Did those entrys slip in there by accident?


Solution

  • As of net core framework 3.0 they are required (the application fails under certain scenarios).

    These PDBs are used by the library in an unorthodox way, to generate stack traces and information that is currently required for it to work properly.

    However, in Native libraries not loaded in C# interactive, it seems that with a brand new client, those dependencies should go away, and therefore should no longer be published.

    However, Unable to load DLL 'Microsoft.Data.SqlClient.SNI.x86.dll' and Microsoft.Data.SqlClient.SNI not deployed along with WebForms others have issues too, particularly when deploying on the cloud, and all of our net-5 projects do include them in their manifest. This could be caused by Entity Framework referencing an old version of the client.