|
2 | 2 | <Project>
|
3 | 3 | <Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
|
4 | 4 |
|
| 5 | + <ItemGroup Condition="'$(IsUnitTestProject)' == 'true'"> |
| 6 | + <PackageReference Include="coverlet.msbuild" Version="2.9.0" PrivateAssets="all" /> |
| 7 | + </ItemGroup> |
| 8 | + |
5 | 9 | <Target Name="CopyNativeAssembiles" AfterTargets="CopyFilesToOutputDirectory">
|
6 | 10 | <PropertyGroup>
|
7 | 11 | <LibPrefix Condition="'$(OS)' != 'Windows_NT'">lib</LibPrefix>
|
|
35 | 39 | <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
|
36 | 40 | </Copy>
|
37 | 41 | </Target>
|
| 42 | + <PropertyGroup Condition="'$(Coverage)' == 'true'"> |
| 43 | + <!-- https://github.com/tonerdo/coverlet/issues/363 --> |
| 44 | + <DeterministicSourcePaths>false</DeterministicSourcePaths> |
| 45 | + |
| 46 | + <!-- https://github.com/tonerdo/coverlet/issues/618 --> |
| 47 | + <IncludeTestAssembly>true</IncludeTestAssembly> |
| 48 | + |
| 49 | + <CollectCoverage>true</CollectCoverage> |
| 50 | + <SingleHit>true</SingleHit> |
| 51 | + <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> |
| 52 | + <CoverletOutputFormat>opencover</CoverletOutputFormat> |
| 53 | + <CoverletOutput>$(BaseOutputPath)$(PlatformConfig)\coverage\coverage.opencover.xml</CoverletOutput> |
| 54 | + <Include></Include> |
| 55 | + <Exclude></Exclude> |
| 56 | + <ExcludeByAttribute>ExcludeFromCodeCoverage</ExcludeByAttribute> |
| 57 | + <ExcludeByFile></ExcludeByFile> |
| 58 | + </PropertyGroup> |
| 59 | + |
| 60 | + <Target Name="OuterInstrumentModulesNoBuild" BeforeTargets="RunTests" Condition="'$(IsUnitTestProject)' == 'true' AND '$(TargetFramework)' == ''"> |
| 61 | + <MSBuild |
| 62 | + Projects="$(MSBuildProjectFullPath)" |
| 63 | + Targets="InnerInstrumentModulesNoBuild" |
| 64 | + Properties="TargetFramework=%(_TargetFramework.Identity)" /> |
| 65 | + </Target> |
| 66 | + |
| 67 | + <Target Name="OuterGenerateCoverageResult" BeforeTargets="Test" Condition="'$(IsUnitTestProject)' == 'true' AND '$(TargetFramework)' == ''"> |
| 68 | + <MSBuild |
| 69 | + Projects="$(MSBuildProjectFullPath)" |
| 70 | + Targets="InnerGenerateCoverageResult" |
| 71 | + Properties="TargetFramework=%(_TargetFramework.Identity)" /> |
| 72 | + </Target> |
| 73 | + |
| 74 | + <Target Name="InnerInstrumentModulesNoBuild" |
| 75 | + BeforeTargets="RunTests" |
| 76 | + DependsOnTargets="InstrumentModules" |
| 77 | + Condition="'$(IsUnitTestProject)' == 'true' AND '$(TargetFramework)' != '' AND '$(CollectCoverage)' == 'true'" /> |
38 | 78 |
|
| 79 | + <Target Name="InnerGenerateCoverageResult" |
| 80 | + BeforeTargets="Test" |
| 81 | + DependsOnTargets="GenerateCoverageResult" |
| 82 | + Condition="'$(IsUnitTestProject)' == 'true' AND '$(TargetFramework)' != '' AND '$(CollectCoverage)' == 'true'" /> |
39 | 83 | </Project>
|
0 commit comments