Ask questionsTests' build output for netcoreapp3+ mixes the system under test with VsTest implementation details.
.NET Core 3 changed the default behavior of a project's build output folder (see "Build copies dependencies"). For test projects, this has the unfortunate side effect of polluting the test projects' build output folder with test-running infrastructure. In addition to being visually jarring (which is not important), this changes the system under test. The system under test is no longer the one the user intended:
Context in this image:
For instance, the popular Newtonsoft.Json.dll used by the VsTest infrastructure gets copied out here beside the system under test, which could negatively impact behavior if the system under test has its own reference to some other version of the assembly. This is just one example. Even if the user's desired version of Newtonsoft.Json happens to be the one present, the underlying problem remains: we're not testing what we think we are testing. The build output folder is a mix of the system under test, the test adapter's own dependencies, and VsTest testhost infrastructure.
There's hope that this mixing of multiple systems isn't truly necessary:
So, there are two questions:
It appears that the Test SDK's use of NuGet package dependencies essentially overwrites the system under test, and might be the root cause.
Create a solution with a single test project which targets both netcoreapp2.1 and netcoreapp3.1. Build. Inspect the build output folders for both target frameworks.
Build output folder contains the system under test.
Build output folder contains a mix of the system under test, the test adapter's own dependencies, and the VsTest infrastructure.
Answer questions plioi
Some of the implementation details in VsTest, as it prepares to ultimately invoke the test host, makes it look like the primary intended path is for the bin/ folder to NOT contain all these extra assemblies and support files, and that the mode everyone is experiencing was supposed to just be a fallback case.