Skip to content

Instantly share code, notes, and snippets.

@tracker1
Created December 3, 2019 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tracker1/4f184c35208e7b9a3922f69ffb0adaca to your computer and use it in GitHub Desktop.
Save tracker1/4f184c35208e7b9a3922f69ffb0adaca to your computer and use it in GitHub Desktop.
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