This repository has been archived by the owner on Jan 5, 2023. It is now read-only.
forked from clairernovotny/DeterministicBuilds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDirectory.Build.targets
47 lines (42 loc) · 2.15 KB
/
Directory.Build.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<Project>
<!-- Workaround for https://github.com/dotnet/sourcelink/issues/572 -->
<!-- Fixed in .NET Core 3.1.300+ -->
<!--
<PropertyGroup>
<TargetFrameworkMonikerAssemblyAttributesPath>$([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)'))</TargetFrameworkMonikerAssemblyAttributesPath>
</PropertyGroup>
<ItemGroup>
<EmbeddedFiles Include="$(GeneratedAssemblyInfoFile)"/>
</ItemGroup>
-->
<!-- Workaround for https://github.com/dotnet/sdk/issues/11105 -->
<!-- Fixed by https://github.com/NuGet/NuGet.Client/pull/3430 -->
<ItemGroup>
<SourceRoot Include="$(NuGetPackageRoot)" Condition=" '$(NuGetPackageRoot)' != '' " />
</ItemGroup>
<!-- https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/DeterministicBuild.md -->
<!--
Without this target, we may get an empty CC:
OK: dotnet test /p:CollectCoverage=true
EMPTY: dotnet test /p:CollectCoverage=true /p:ContinuousIntegrationBuild=true
OK: dotnet test /p:CollectCoverage=true /p:UseSourceLink=true
EMPTY: dotnet test /p:CollectCoverage=true /p:UseSourceLink=true /p:ContinuousIntegrationBuild=true
With this target, these commands succeed with the current nightly builds of
Coverlet (stable builds throw KeyNotFoundException with the latest command).
Remark:
The reason why the CC report is empty is only indirectly related to
ContinuousIntegrationBuild, the real culprit is DeterministicSourcePaths when
it is set to true.
Deterministic = true (default) and ContinuousIntegrationBuild = true imply
DeterministicSourcePaths = true.
https://github.com/dotnet/roslyn/blob/master/src/Compilers/Core/MSBuildTask/Microsoft.Managed.Core.targets#L131
-->
<Target Name="CoverletGetPathMap"
DependsOnTargets="InitializeSourceRootMappedPaths"
Returns="@(_LocalTopLevelSourceRoot)"
Condition=" '$(DeterministicSourcePaths)' == 'true' ">
<ItemGroup>
<_LocalTopLevelSourceRoot Include="@(SourceRoot)" Condition="'%(SourceRoot.NestedRoot)' == ''"/>
</ItemGroup>
</Target>
</Project>