Skip to content

Commit 3570fc9

Browse files
authored
Merge pull request #434 from AArnott/incrementalbuild
Fix `dotnet build` of a clean repo
2 parents 13c2e2b + dfda81a commit 3570fc9

File tree

8 files changed

+34
-22
lines changed

8 files changed

+34
-22
lines changed

Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project>
33
<PropertyGroup>
4+
<RepoRoot>$(MSBuildThisFileDirectory)</RepoRoot>
45
<PackageOutputPath>$(MSBuildThisFileDirectory)build\$(Configuration)\</PackageOutputPath>
56
</PropertyGroup>
67

build.proj

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,7 @@
1313
<Exec Command="dotnet build &quot;$(MSBuildThisFileDirectory)src\coverlet.collector\coverlet.collector.csproj&quot; -c $(Configuration)" />
1414
</Target>
1515

16-
<Target Name="PublishMSBuildTaskProject" AfterTargets="BuildAllProjects">
17-
<Exec Command="dotnet publish &quot;$(MSBuildThisFileDirectory)src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj&quot; -c $(Configuration) -o &quot;$(OutputPath)&quot;" />
18-
</Target>
19-
20-
<Target Name="CopyMSBuildScripts" AfterTargets="PublishMSBuildTaskProject">
21-
<ItemGroup>
22-
<BuildScript Include="$(MSBuildThisFileDirectory)src\coverlet.msbuild.tasks\coverlet.msbuild.props" />
23-
<BuildScript Include="$(MSBuildThisFileDirectory)src\coverlet.msbuild.tasks\coverlet.msbuild.targets" />
24-
</ItemGroup>
25-
<Copy SourceFiles="@(BuildScript)" DestinationFolder="$(OutputPath)" />
26-
</Target>
27-
28-
<Target Name="RunTests" AfterTargets="CopyMSBuildScripts">
16+
<Target Name="RunTests" AfterTargets="BuildAllProjects">
2917
<Exec Command="dotnet test &quot;$(MSBuildThisFileDirectory)test\coverlet.core.tests\coverlet.core.tests.csproj&quot; -c $(Configuration) /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Include=[coverlet.*]*"/>
3018
<Exec Command="dotnet test &quot;$(MSBuildThisFileDirectory)test\coverlet.collector.tests\coverlet.collector.tests.csproj&quot; -c $(Configuration) /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Include=[coverlet.*]*"/>
3119
</Target>

src/coverlet.msbuild.tasks/coverlet.msbuild.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@
1616
<ThresholdType Condition="$(ThresholdType) == ''">line,branch,method</ThresholdType>
1717
<ThresholdStat Condition="$(ThresholdStat) == ''">minimum</ThresholdStat>
1818
</PropertyGroup>
19+
<PropertyGroup>
20+
<CoverletToolsPath Condition=" '$(CoverletToolsPath)' == '' ">$(MSBuildThisFileDirectory)</CoverletToolsPath>
21+
</PropertyGroup>
1922
</Project>

src/coverlet.msbuild.tasks/coverlet.msbuild.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22

3-
<UsingTask TaskName="Coverlet.MSbuild.Tasks.InstrumentationTask" AssemblyFile="$(MSBuildThisFileDirectory)coverlet.msbuild.tasks.dll"/>
4-
<UsingTask TaskName="Coverlet.MSbuild.Tasks.CoverageResultTask" AssemblyFile="$(MSBuildThisFileDirectory)coverlet.msbuild.tasks.dll"/>
3+
<UsingTask TaskName="Coverlet.MSbuild.Tasks.InstrumentationTask" AssemblyFile="$(CoverletToolsPath)coverlet.msbuild.tasks.dll"/>
4+
<UsingTask TaskName="Coverlet.MSbuild.Tasks.CoverageResultTask" AssemblyFile="$(CoverletToolsPath)coverlet.msbuild.tasks.dll"/>
55

66
<Target Name="InstrumentModulesNoBuild" BeforeTargets="VSTest">
77
<Coverlet.MSbuild.Tasks.InstrumentationTask

test/Directory.Build.targets

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project>
2+
<Choose>
3+
<!-- This condition tests whether coverlet.msbuild.props has been imported by the project -->
4+
<When Condition=" '$(ThresholdType)' != '' ">
5+
<ItemGroup>
6+
<!-- Arrange for the project that builds the build tools has built first. -->
7+
<ProjectReference Include="$(RepoRoot)src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj">
8+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
9+
</ProjectReference>
10+
</ItemGroup>
11+
<PropertyGroup>
12+
<!-- Ensure that the built tools can be found at build time.
13+
This is required when the coverlet.msbuild imports are made in their src directory
14+
(so that msbuild eval works even before they are built)
15+
so that they can still find the tooling that will be built by the build. -->
16+
<CoverletToolsPath>$(RepoRoot)src\coverlet.msbuild.tasks\bin\$(Configuration)\netstandard2.0\</CoverletToolsPath>
17+
</PropertyGroup>
18+
</When>
19+
</Choose>
20+
</Project>

test/coverlet.collector.tests/coverlet.collector.tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<ProjectReference Include="..\..\src\coverlet.core\coverlet.core.csproj" />
22-
<ProjectReference Include="..\..\src\coverlet.collector\coverlet.collector.csproj" />
21+
<ProjectReference Include="$(RepoRoot)src\coverlet.core\coverlet.core.csproj" />
22+
<ProjectReference Include="$(RepoRoot)src\coverlet.collector\coverlet.collector.csproj" />
2323
</ItemGroup>
2424

2525
</Project>

test/coverlet.core.performancetest/coverlet.core.performancetest.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
<Import Project="$(MSBuildThisFileDirectory)\..\..\build\$(Configuration)\coverlet.msbuild.props" />
2+
<Import Project="$(RepoRoot)src\coverlet.msbuild.tasks\coverlet.msbuild.props" />
33

44
<PropertyGroup>
55
<TargetFramework>netcoreapp2.0</TargetFramework>
@@ -15,5 +15,5 @@
1515
<ProjectReference Include="..\coverlet.testsubject\coverlet.testsubject.csproj" />
1616
</ItemGroup>
1717

18-
<Import Project="$(MSBuildThisFileDirectory)\..\..\build\$(Configuration)\coverlet.msbuild.targets" />
18+
<Import Project="$(RepoRoot)src\coverlet.msbuild.tasks\coverlet.msbuild.targets" />
1919
</Project>

test/coverlet.core.tests/coverlet.core.tests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
<Import Project="$(MSBuildThisFileDirectory)\..\..\build\$(Configuration)\coverlet.msbuild.props" />
2+
<Import Project="$(RepoRoot)src\coverlet.msbuild.tasks\coverlet.msbuild.props" />
33

44
<PropertyGroup>
55
<TargetFramework>netcoreapp2.0</TargetFramework>
@@ -16,8 +16,8 @@
1616
</ItemGroup>
1717

1818
<ItemGroup>
19-
<ProjectReference Include="..\..\src\coverlet.core\coverlet.core.csproj" />
19+
<ProjectReference Include="$(RepoRoot)src\coverlet.core\coverlet.core.csproj" />
2020
</ItemGroup>
2121

22-
<Import Project="$(MSBuildThisFileDirectory)\..\..\build\$(Configuration)\coverlet.msbuild.targets" />
22+
<Import Project="$(RepoRoot)src\coverlet.msbuild.tasks\coverlet.msbuild.targets" />
2323
</Project>

0 commit comments

Comments
 (0)