-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Copy dll from global‑packages to output #10518
Comments
This is already the default behavior for 3.0. We will copy all assets during build to the build output. If you use .NET Core 3.0.100, you should see that behavior. Also, you can force that to happen by setting Let us know if any of these work for you. |
Did some test
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<IsPackable>false</IsPackable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="Microsoft.AspNetCore.All" /> <-- without this it works
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" />
</ItemGroup>
</Project>
|
How exactly does it fail? It just does not copy the files? Could you share binlogs for these with us? Or a repro repo on github we could use? If you decide to share binlogs, please take a look at https://aka.ms/binlog. |
Yep, with csproj above I cannot copy Simple repro above.
|
When you add the asp.net package, that dll exists in the shared framework, so we are picking it from the shared framework and therefore we are not binplacing it. |
That was my suspect...so is there a solution(for runtime under 3.0) or workaround...or the only way is "manual" copy of dll? |
Is there a way to know shared framework path(the correct version) through code?I could try to find the lib there. |
Or some trick on csproj PackageReference to move dll to output. |
@dsplaisted @nguerrera any ideas? |
@jeffschwMSFT / @jbevain Is there a good way to programmatically resolve assemblies from the shared framework in order for Mono.Cecil to be able to analyze / instrument user assemblies? If reference assemblies will work, you may be able to use |
@MarcoRossignoli would reference assemblies work, as @dsplaisted asked above? |
@livarcocc I've added |
There was a related discussion at https://github.com/dotnet/core-setup/issues/4975 |
This should create a |
@dasMulli thanks's, do you know where is this logic?Some repo link?I know that is fragile and could change in future...but maybe we could reach best-effort. |
Most of it is in https://github.com/dotnet/core-setup/blob/master/Documentation/design-docs/multilevel-sharedfx-lookup.md, https://github.com/dotnet/core-setup/blob/master/Documentation/design-docs/host-probing.md and other files in that directory. Though i'm sure you could try some hacks to simplify it whil covering 90%+ of user configurations. |
That seems fine for the purpose at hand to me. Why would you need implementation of framework to instrument user assemblies? I'd like to understand more about why https://github.com/dotnet/cli/issues/12705#issuecomment-539440201 didn't work out. Do you have a repro of that approach failing? Is it possibly same as disccussed in https://github.com/dotnet/core-setup/issues/8490 where you need to also set PreserveCompilationReferences=true in ASP.NET Core 3.0 projects? |
@nguerrera when we instrument Cecil need to load types that are present on shared framework or it fails. The only workaround now is manual copy missing dll to output. Sample is here https://github.com/dotnet/cli/issues/12705#issuecomment-536685114 If I add |
The question is more if it would be enough for Cecil to load types from reference assemblies for reflection purposes, similar to how the reference assemblies for compilation are passed to roslyn/csc for compilation. |
In these case I think so...we instrument and re-write only users dll not dependencies. |
PreserveCompilationContext should however cause your deps.json file to contain references to the DLL files being used (in "compile" lists) which can be found by applying the package name/version and relative path to one of the paths listed in xyz.runtimeconfig.dev.json as additional probing paths. So in my case: {
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\ullrimar\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\ullrimar\\.nuget\\packages",
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
]
}
} xyz.deps.json: "Microsoft.Extensions.Logging.Abstractions/2.2.0": {
"compile": {
"lib/netstandard2.0/Microsoft.Extensions.Logging.Abstractions.dll": {}
},
"compileOnly": true
}, Can be found in When you call |
@dasMulli @livarcocc @dsplaisted is there a way to load a
I get null ref...I'm inside msbuild task so I think that I cannot use |
Thank's to https://github.com/dotnet/core-setup/issues/8805 and |
Hi I'm Marco from coverlet https://github.com/tonerdo/coverlet
We have an issue with instrumentation through cecil, I'll explain what's happen.
Coverlet is usable through 3 drivers, msbuild, dotnet tool and vstest collectors, and it works for full and core .NET
After a user fire the test command with coverage enabled coverlet instrument needed assemblies.
To do that we use Mono.Cecil.
Mono.Cecil sometimes need to load referenced assemblies, but it fails to load transitive reference(for instance testing apps that uses
Microsoft.Extensions.Logging.Abstractions
)Default cecil resolver does not resolve from global-packages location.
One solution users try is to reference missed dll in csproj, but it doesn't work because there is no way to "copy PackageReference dll to output folder", i.e. on test project:
Now my question: is there a way to force the copy of
PackageReference
dll on output folder?Another approach I'm testing is to resolve reference by myself on custom resolver(with one of our user case it works)...but I think's it not possible, because for instance with dotnet tool I'll instrument always with "dotnet core runtime" but I could test full framework app, so I'll load incorrect dll...again with multitarget libs it's a hell, because we need to implement all loading rule with runtime/version matrix.
Current workaround is manual copy dll on output folder.
Coverlet reference issue coverlet-coverage/coverlet#560
cc: @tonerdo
The text was updated successfully, but these errors were encountered: