Skip to content

Commit 496182f

Browse files
committed
Update coverlet.msbuild.tasks to support .NET Framework
1 parent a646c2d commit 496182f

File tree

7 files changed

+17
-11
lines changed

7 files changed

+17
-11
lines changed

build.proj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
<PropertyGroup>
44
<Configuration Condition="$(Configuration) == ''">Debug</Configuration>
55
<OutputPath>$(MSBuildThisFileDirectory)build\$(Configuration)</OutputPath>
6+
<TargetFrameworkOverride Condition="'$(APPVEYOR_BUILD_WORKER_IMAGE)' == 'Ubuntu'">-f netcoreapp2.0</TargetFrameworkOverride>
67
</PropertyGroup>
78

89
<Target Name="BuildAllProjects">
910
<RemoveDir Directories="$(OutputPath)" Condition="Exists('$(MSBuildThisFileDirectory)\build')" />
10-
<Exec Command="dotnet build &quot;$(MSBuildThisFileDirectory)src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj&quot; -c $(Configuration)" />
11+
<Exec Command="dotnet build &quot;$(MSBuildThisFileDirectory)src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj&quot; -c $(Configuration) $(TargetFrameworkOverride)" />
1112
<Exec Command="dotnet build &quot;$(MSBuildThisFileDirectory)src\coverlet.console\coverlet.console.csproj&quot; -c $(Configuration)" />
1213
</Target>
1314

1415
<Target Name="PublishMSBuildTaskProject" AfterTargets="BuildAllProjects">
15-
<Exec Command="dotnet publish &quot;$(MSBuildThisFileDirectory)src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj&quot; -c $(Configuration) -o &quot;$(OutputPath)\netcoreapp2.0&quot;" />
16+
<Exec Command="dotnet publish &quot;$(MSBuildThisFileDirectory)src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj&quot; -c $(Configuration) -f netcoreapp2.0 -o &quot;$(OutputPath)\netcoreapp2.0&quot;" />
1617
</Target>
1718

1819
<Target Name="CopyMSBuildScripts" AfterTargets="PublishMSBuildTaskProject">

src/coverlet.core/Coverage.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,10 @@ private string GetSourceLinkUrl(Dictionary<string, string> sourceLinkDocuments,
275275
string key = sourceLinkDocument.Key;
276276
if (Path.GetFileName(key) != "*") continue;
277277

278-
string relativePath = Path.GetRelativePath(Path.GetDirectoryName(key), Path.GetDirectoryName(document));
278+
if (!Path.GetDirectoryName(document).StartsWith(Path.GetDirectoryName(key) + Path.DirectorySeparatorChar))
279+
continue;
279280

280-
if (relativePath.Contains("..")) continue;
281+
var relativePath = Path.GetDirectoryName(document).Substring(Path.GetDirectoryName(key).Length + 1);
281282

282283
if (relativePathOfBestMatch.Length == 0)
283284
{

src/coverlet.core/coverlet.core.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>Library</OutputType>
5-
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
<TargetFrameworks>netcoreapp2.0;net472</TargetFrameworks>
66
<AssemblyVersion>4.1.0</AssemblyVersion>
77
</PropertyGroup>
88

99
<ItemGroup>
1010
<PackageReference Include="Mono.Cecil" Version="0.10.1" />
1111
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
12+
<PackageReference Include="System.Reflection.Metadata" Version="1.6.0" />
1213
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="2.0.1" />
1314
</ItemGroup>
1415

src/coverlet.msbuild.tasks/coverlet.msbuild.tasks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Library</OutputType>
5-
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
<TargetFrameworks>netcoreapp2.0;net472</TargetFrameworks>
66
<AssemblyVersion>2.4.0</AssemblyVersion>
77

88
<PackageId>coverlet.msbuild</PackageId>

src/coverlet.msbuild/coverlet.msbuild.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@
1313
<Threshold Condition="$(Threshold) == ''">0</Threshold>
1414
<ThresholdType Condition="$(ThresholdType) == ''">line,branch,method</ThresholdType>
1515
<ThresholdStat Condition="$(ThresholdStat) == ''">minimum</ThresholdStat>
16+
17+
<CoverletBuildTaskPath Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)net472\</CoverletBuildTaskPath>
18+
<CoverletBuildTaskPath Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)netcoreapp2.0\</CoverletBuildTaskPath>
1619
</PropertyGroup>
1720
</Project>

src/coverlet.msbuild/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)netcoreapp2.0\coverlet.msbuild.tasks.dll"/>
4-
<UsingTask TaskName="Coverlet.MSbuild.Tasks.CoverageResultTask" AssemblyFile="$(MSBuildThisFileDirectory)netcoreapp2.0\coverlet.msbuild.tasks.dll"/>
3+
<UsingTask TaskName="Coverlet.MSbuild.Tasks.InstrumentationTask" AssemblyFile="$(CoverletBuildTaskPath)coverlet.msbuild.tasks.dll"/>
4+
<UsingTask TaskName="Coverlet.MSbuild.Tasks.CoverageResultTask" AssemblyFile="$(CoverletBuildTaskPath)coverlet.msbuild.tasks.dll"/>
55

66
<Target Name="InstrumentModulesNoBuild" BeforeTargets="VSTest">
77
<Coverlet.MSbuild.Tasks.InstrumentationTask
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFrameworks>netcoreapp2.0;net472</TargetFrameworks>
55
</PropertyGroup>
66

77
</Project>

0 commit comments

Comments
 (0)