Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
DotNet Core 3, XUnit, Integrated Tests With Coverage
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- Add to be able to test default assembly -->
<GenerateProgramFile>false</GenerateProgramFile>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RootNamespace>ProjectName</RootNamespace>
<!-- Needed to exclude *.Test.cs from Release Build -->
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.7.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<!-- Needed Non-Release Build, include *.Test.cs -->
<ItemGroup Condition="'$(Configuration)' != 'Release'">
<Compile Include="**/*.cs" />
</ItemGroup>
<!-- Needed Release Build, exclude *.Test.cs -->
<ItemGroup Condition="'$(Configuration)' == 'Release'">
<Compile Include="**/*.cs" Exclude="**/*.Test.cs" />
</ItemGroup>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment