Open ldubrois opened 5 years ago
Can you share what your project looks like? And what the nuspec for p1 looks like as well, or the package?
I've created a very dumb project to illustrate the point : MS_NugetBug_Sample.zip
Just with F5 on P2, the type is not found. If you publish the app, the type is found.
If you uncomment the first line in P2, making an explicit reference to P1, the with F5 and publish, it does work.
While making the sample project I've constated a difference between net core app 2.2 and net core app 3.0. The failing case in 2.2 is passing in 3.0.
In 2.2, the P1.dll file is not in the debug build directory, while with the exact same code, in 3.0, P1.dll is in the debug build directory.
Hi,
Any news on this issue ?
Regards,
Luke
@ldubrois I'm just starting my search on this so take this with a grain of salt.
The reason reflection isn't finding your stuff is because it isn't there. The NuGet package is a .zip containing your .dlls, not the .dlls themselves. If you wanted to you could extract the .dlls out of it at runtime, but that seems hacky and I'm trying to avoid doing this myself.
Steps to reproduce
I have a project P1 containing a class C1 and C2. I publish it as a nuget package P1.
In an another solution, I create a console project P2, add a nuget reference to P1. The code in the project P2 tries to find by reflection C1.
From Visual Studio (2017 & 2019), I start the P2 project (F5).
Expected behavior
I should find the type C1.
Actual behavior
C1 and the P1 assembly does not exists.
If I publish the project, the P1 dll is present and the app works fine.
Still in Visual Studio, if I had a direct reference to C2 in the P2 project, then I can find C1 by reflection.
Visual Studio (msbuild) seems to make 'optimizations' and does not provide correctly the nuget dependencies if they are only used by reflection.
Environment data
msbuild /version
output:OS info: