Skip to content

Fix dotnet build of a clean repo #434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<RepoRoot>$(MSBuildThisFileDirectory)</RepoRoot>
<PackageOutputPath>$(MSBuildThisFileDirectory)build\$(Configuration)\</PackageOutputPath>
</PropertyGroup>

Expand Down
14 changes: 1 addition & 13 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,7 @@
<Exec Command="dotnet build &quot;$(MSBuildThisFileDirectory)src\coverlet.collector\coverlet.collector.csproj&quot; -c $(Configuration)" />
</Target>

<Target Name="PublishMSBuildTaskProject" AfterTargets="BuildAllProjects">
<Exec Command="dotnet publish &quot;$(MSBuildThisFileDirectory)src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj&quot; -c $(Configuration) -o &quot;$(OutputPath)&quot;" />
</Target>

<Target Name="CopyMSBuildScripts" AfterTargets="PublishMSBuildTaskProject">
<ItemGroup>
<BuildScript Include="$(MSBuildThisFileDirectory)src\coverlet.msbuild.tasks\coverlet.msbuild.props" />
<BuildScript Include="$(MSBuildThisFileDirectory)src\coverlet.msbuild.tasks\coverlet.msbuild.targets" />
</ItemGroup>
<Copy SourceFiles="@(BuildScript)" DestinationFolder="$(OutputPath)" />
</Target>

<Target Name="RunTests" AfterTargets="CopyMSBuildScripts">
<Target Name="RunTests" AfterTargets="BuildAllProjects">
<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.*]*"/>
<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.*]*"/>
</Target>
Expand Down
3 changes: 3 additions & 0 deletions src/coverlet.msbuild.tasks/coverlet.msbuild.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@
<ThresholdType Condition="$(ThresholdType) == ''">line,branch,method</ThresholdType>
<ThresholdStat Condition="$(ThresholdStat) == ''">minimum</ThresholdStat>
</PropertyGroup>
<PropertyGroup>
<CoverletToolsPath Condition=" '$(CoverletToolsPath)' == '' ">$(MSBuildThisFileDirectory)</CoverletToolsPath>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions src/coverlet.msbuild.tasks/coverlet.msbuild.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

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

<Target Name="InstrumentModulesNoBuild" BeforeTargets="VSTest">
<Coverlet.MSbuild.Tasks.InstrumentationTask
Expand Down
20 changes: 20 additions & 0 deletions test/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project>
<Choose>
<!-- This condition tests whether coverlet.msbuild.props has been imported by the project -->
<When Condition=" '$(ThresholdType)' != '' ">
<ItemGroup>
<!-- Arrange for the project that builds the build tools has built first. -->
<ProjectReference Include="$(RepoRoot)src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<!-- Ensure that the built tools can be found at build time.
This is required when the coverlet.msbuild imports are made in their src directory
(so that msbuild eval works even before they are built)
so that they can still find the tooling that will be built by the build. -->
<CoverletToolsPath>$(RepoRoot)src\coverlet.msbuild.tasks\bin\$(Configuration)\netstandard2.0\</CoverletToolsPath>
</PropertyGroup>
</When>
</Choose>
</Project>
4 changes: 2 additions & 2 deletions test/coverlet.collector.tests/coverlet.collector.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\coverlet.core\coverlet.core.csproj" />
<ProjectReference Include="..\..\src\coverlet.collector\coverlet.collector.csproj" />
<ProjectReference Include="$(RepoRoot)src\coverlet.core\coverlet.core.csproj" />
<ProjectReference Include="$(RepoRoot)src\coverlet.collector\coverlet.collector.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(MSBuildThisFileDirectory)\..\..\build\$(Configuration)\coverlet.msbuild.props" />
<Import Project="$(RepoRoot)src\coverlet.msbuild.tasks\coverlet.msbuild.props" />

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
Expand All @@ -15,5 +15,5 @@
<ProjectReference Include="..\coverlet.testsubject\coverlet.testsubject.csproj" />
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)\..\..\build\$(Configuration)\coverlet.msbuild.targets" />
<Import Project="$(RepoRoot)src\coverlet.msbuild.tasks\coverlet.msbuild.targets" />
</Project>
6 changes: 3 additions & 3 deletions test/coverlet.core.tests/coverlet.core.tests.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(MSBuildThisFileDirectory)\..\..\build\$(Configuration)\coverlet.msbuild.props" />
<Import Project="$(RepoRoot)src\coverlet.msbuild.tasks\coverlet.msbuild.props" />

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
Expand All @@ -16,8 +16,8 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\coverlet.core\coverlet.core.csproj" />
<ProjectReference Include="$(RepoRoot)src\coverlet.core\coverlet.core.csproj" />
</ItemGroup>

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