EgorBo / Disasmo

VS2022 Add-in. Click on any method or class to see what .NET Core's JIT generates for them (ASM).
MIT License
638 stars 39 forks source link

Switch to "dotnet build" leads to missing dependencies for libraries #17

Closed SingleAccretion closed 3 years ago

SingleAccretion commented 3 years ago

I hit this when trying to disasm a method in a plain (only shared framework dependencies) net5.0 library. It was failing with could not load System.Runtime Version=5.0.0. After some investigation I determined that the cause of the error is the fact that Disasmo is now using dotnet build (presumably, for its higher performance) instead of dotnet publish to get the project's artifacts.

This does not work for libraries, as they, apparently, are built without the framework dependencies being copied to the output. Then CoreRun fails to find them and things do no work as expected.

The "easy" workaround would be to switch back to dotnet publish --self-contained true (note that plain publish does not work for libraries). I suspect, however, that the switch was deliberate and that would be a regression. Maybe CoreRun has some options for probing (I am not an expert in this area)?

Right now I am using a workaround of running a target that would publish my library to the Disasmo's folder after build. FWIW, it works, but it is not pretty.

EgorBo commented 3 years ago

@SingleAccretion thanks for the feedback! I never tested it against Libs so will take a look.

Maybe CoreRun has some options

The command I promote to build the runtime doesn't produce CoreRun:

build.cmd Clr -c Checked

In order to produce the CoreRun we'll have to also request the Libs subset and build it twice basically:

build.cmd Clr+Libs -c Release
build.cmd Clr -c Checked

It complicates things a lot 🙁 and takes much much longer time to finish.

SingleAccretion commented 3 years ago

In order to produce the CoreRun we'll have to also request the Libs subset and build it twice basically

Hmm, I am clearly missing something here. Doesn't Disasmo use CoreRun already? https://github.com/EgorBo/Disasmo/blob/d32c94f9c766fbe8646a7c5e7175fb8609d4c6e5/src/Vsix/ViewModels/MainViewModel.cs#L146

FWIW, I did build the libs, but it worked for me without that in console projects.

P.S.: one thing that I noticed is that the disassembly has managed asserts. I suppose that's expected with the Checked CoreLib?

EgorBo commented 3 years ago

Thanks, should work now for libs as well (I checked)