jcansdale / TestDriven.Net-Issues

Issue tracking for TestDriven.Net
https://github.com/jcansdale/TestDriven.Net-Issues/issues
24 stars 2 forks source link

Executing ad-hoc test methods in .NET Standard projects #117

Open jcansdale opened 6 years ago

jcansdale commented 6 years ago

.NET Standard projects

.NET Standard projects are designed to run on multiple different .NET platforms (.NET Core, .NET Framework, Mono etc). When asked to run an ad-hoc test method, TestDriven.Net will attempt to execute it using the same .NET Framework version as Visual Studio.

The .NET Core and .NET Framework have different assembly resolution strategies. .NET Framework expects assemblies to be on the application base, the GAC or resolved using a custom assembly resolve event. .NET Core specifies its dependencies in a .deps.json file.

In order to resolve any referenced assemblies when using the .NET Framework, you will need to copy and dependencies to the application base. This can be done by setting the CopyLocalLockFileAssemblies property to true in your .NET Standard project file. For example:

<Project Sdk='Microsoft.NET.Sdk'>
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
  </PropertyGroup>
</Project>

Hints and tips

I'm planning to support this by default in the next release.

What isn't supported

Because the project doesn't know which runtime is being targeted, CopyLocalLockFileAssemblies doesn't know which native dependencies to copy.

It will work with NuGet packages that copy native dependencies so they are portable across multiple (for example LibGit2Sharp.Portable).

If there are conflicting assembly versions references between NuGet packages it doesn't know how to create an App.config that consolidates the versions.

Related

Any questions?

Please ask questions and share any tips you have below.