Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdb not found when running single exe that contains native dependencies #3807

Closed
ztl8702 opened this issue Oct 14, 2019 · 8 comments
Closed
Labels
area-HostModel Microsoft.NET.HostModel issues

Comments

@ztl8702
Copy link

ztl8702 commented Oct 14, 2019

Steps to reproduce

I have a simple console app which has a dependency on Libgit2Sharp, which contains native binaries. When published as a single EXE, it fails to run.

git clone https://github.com/ztl8702/dotnet-core-single-exe-repro.git
cd dotnet-core-single-exe-repro/ConsoleAppUsingLibgit
dotnet publish -r win-x86 -c Release -o $env:HOME\bin-x86\ ConsoleAppUsingLibgit.csproj /p:PublishSingleFile=true /p:PublishTrimmed=true;
$env:HOME\bin-x86\ConsoleAppUsingLibgit.exe

Expected behavior

Console app runs, and should output something like:

Hello World! This app uses LibGit2Sharp
Latest commit: add tests to CI config

Actual behavior

Fails to run, with error:

Error:
  An assembly specified in the application dependencies manifest (ConsoleAppUsingLibgit.deps.json) was not found:
    package: 'LibGit2Sharp.NativeBinaries', version: '2.0.289'
    path: 'runtimes/win-x64/native/git2-7ce88e6.pdb'

I have set up CI on Github Actions to reproduce this.

See https://github.com/ztl8702/dotnet-core-single-exe-repro/runs/259587098 (and expand the logs for the "Test ..." steps)

Publishing without using single exe works fine.

Environment data

.NET Core SDK: 3.0.100
Operating system (reproducible when running the single exe on):

  • Windows 8 (32-bit)
  • Windows 10 1803 (64-bit)
  • Windows Server 2019 (Github Action runner)
@ztl8702
Copy link
Author

ztl8702 commented Oct 15, 2019

Ok. So I tried creating another sample app that uses Grpc.Core (the C version); and it works fine.

https://github.com/ztl8702/dotnet-core-single-exe-repro/runs/260574843

So this might be an issue specific to Libgit2Sharp....

Still, I would appreciate any ideas on how to debug.

@ztl8702
Copy link
Author

ztl8702 commented Oct 15, 2019

So it appears that the libgit2sharp.nativebinaries NuGet package contains .pdb files for the native dlls (e.g. git2-7ce88e6.pdb). dotnet publish copies it to output, but single exe strips it. However ConsoleAppUsingLibgit.deps.json still contains a reference to that pdb file.

@dagood
Copy link
Member

dagood commented Oct 15, 2019

The bundle task has an IncludeSymbols switch that it looks like you should be able to set via /p:IncludeSymbolsInSingleFile=true. I think your scenario is a little unusual because you have a NuGet package with a PDB in it, not sure whether the bundler is expecting that.

@swaroop-sridhar

@ztl8702
Copy link
Author

ztl8702 commented Oct 15, 2019

Setting /p:IncludeSymbolsInSingleFile=true works!

@ztl8702
Copy link
Author

ztl8702 commented Oct 15, 2019

So the logic here:
https://github.com/dotnet/core-setup/blob/119d6f9ad450a81c0b93491adebc8090ee10858a/src/managed/Microsoft.NET.HostModel/Bundle/Bundler.cs#L95-L98

Should be changed to something like: if EmbedPDBs || if the pdb is referenced in deps.json?

@dagood
Copy link
Member

dagood commented Oct 15, 2019

That sounds reasonable to me, I'm not familiar with this code though. (That ToLower rather than ToLowerInvariant is also interesting there.)

@swaroop-sridhar
Copy link
Contributor

This issue is a dup of dotnet/sdk#3685
Please see the discussion in dotnet/sdk#3685 for more details.

@dagood, I'll fix the ToLower() issue. Thanks for pointing it out.

@klalle
Copy link

klalle commented Jan 21, 2020

The bundle task has an IncludeSymbols switch that it looks like you should be able to set via /p:IncludeSymbolsInSingleFile=true. I think your scenario is a little unusual because you have a NuGet package with a PDB in it, not sure whether the bundler is expecting that.

@swaroop-sridhar

This does not work when the project containing the nuget with native pdb files (ex Microsoft.ML.onnxruntime) is a .net core 3 project, and referenced in a Windows Application Packaging Project (to pack as UWP)... Then it seams impossible to either discard the pbd files, or to include them in the single file (which the packaging project is totally responsible for)...
I finally managed to find a workaround with a postbuildscript, see here: https://github.com/klalle/Microsoft.ML.onnxruntime_UWP_fix
Any other solutions is apreciated!

@msftgits msftgits transferred this issue from dotnet/core-setup Jan 30, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-HostModel Microsoft.NET.HostModel issues
Projects
None yet
Development

No branches or pull requests

4 participants