How to properly unit test a .NET project with multiple target frameworks, given implementation differences among targets?

First, test projects can multi-target as well by making use of the <TargetFrameworks>property just like you used for the library. While the VS test runner currently only shows/runs one framework (the first one to be specific), any invocation of dotnet test will execute all frameworks (xunit is also developing custom console runner – dotnet xunit …

Read more

How do I exclude files/folders from a .NET Core/Standard project?

There are also a few things you can do in the csproj files to make sure the files aren’t picked up: 1) Make sure none of the globbing patterns that look for “project items” pick up the files: <PropertyGroup> <DefaultItemExcludes>$(DefaultItemExcludes);your_nonproj.file;a\**\*.pattern</DefaultItemExcludes> </PropertyGroup> 2) Remove items explicitly: <ItemGroup> <None Remove=”hidden.file” /> <Content Remove=”wwwroot\lib\**\*” /> </ItemGroup> Note that, …

Read more

Convert .NET Core 2.0 class libraries to .NET Standard

In the project file, you can point target compilation to netstandard with the exact version. Example of Proj.csproj: <Project Sdk=”Microsoft.NET.Sdk”> <PropertyGroup> <TargetFramework>netstandard1.6</TargetFramework> </PropertyGroup> </Project> … Microsoft provides good documentation about targeting types. Dotnet Standard is not a framework or a library, it is an abstract set of instructions: what functionality should have System.Array, String, List, …

Read more