dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.7k stars 1.06k forks source link

.NET multi target frameworks copies System.* DLLs to .NET Framework output directory #18143

Open IIFE opened 3 years ago

IIFE commented 3 years ago

I've got a .NET project that targets multiple frameworks, i.e., <TargetFrameworks>netstandard2.1;net472</TargetFrameworks>

The project contains NuGet packages that bring in System.* dependencies like System.Memory and System.Buffers.

When I build the project it creates two output directories, netstandard2.1 and net472, which is fine.

The bit I'm struggling to understand is why does the net472 output directory contain the System.* dependencies? I understand them being copied to the netstandard2.1 directory, but why are they copied for the .NET Framework directory when they can be loaded from the .NET Framework installation on the machine (i.e., GAC)?

Is there a way to exclude System.* dlls when for the net472 target?

dotnet-issue-labeler[bot] commented 3 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

dsplaisted commented 3 years ago

I believe support for System.Memory and System.Buffers isn't actually built into .NET 4.7.2, which is why the additional DLLs are needed.

/cc @terrajobst @ericstj

ericstj commented 3 years ago

Correct, System.Memory and System.Buffers were never added to .NETFramework.