Skip to content

Commit

Permalink
Update coverlet.msbuild.tasks to support .NET Framework
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed Jan 16, 2019
1 parent 5fadd27 commit 7235806
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 11 deletions.
5 changes: 3 additions & 2 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
<PropertyGroup>
<Configuration Condition="$(Configuration) == ''">Debug</Configuration>
<OutputPath>$(MSBuildThisFileDirectory)build\$(Configuration)</OutputPath>
<TargetFrameworkOverride Condition="'$(APPVEYOR_BUILD_WORKER_IMAGE)' == 'Ubuntu'">-f netcoreapp2.0</TargetFrameworkOverride>
</PropertyGroup>

<Target Name="BuildAllProjects">
<RemoveDir Directories="$(OutputPath)" Condition="Exists('$(MSBuildThisFileDirectory)\build')" />
<Exec Command="dotnet build &quot;$(MSBuildThisFileDirectory)src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj&quot; -c $(Configuration)" />
<Exec Command="dotnet build &quot;$(MSBuildThisFileDirectory)src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj&quot; -c $(Configuration) $(TargetFrameworkOverride)" />
<Exec Command="dotnet build &quot;$(MSBuildThisFileDirectory)src\coverlet.console\coverlet.console.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)\netcoreapp2.0&quot;" />
<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;" />
</Target>

<Target Name="CopyMSBuildScripts" AfterTargets="PublishMSBuildTaskProject">
Expand Down
5 changes: 3 additions & 2 deletions src/coverlet.core/Coverage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,10 @@ private string GetSourceLinkUrl(Dictionary<string, string> sourceLinkDocuments,
string key = sourceLinkDocument.Key;
if (Path.GetFileName(key) != "*") continue;

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

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

if (relativePathOfBestMatch.Length == 0)
{
Expand Down
5 changes: 3 additions & 2 deletions src/coverlet.core/coverlet.core.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFrameworks>netcoreapp2.0;net472</TargetFrameworks>
<AssemblyVersion>4.1.0</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Mono.Cecil" Version="0.10.1" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="System.Reflection.Metadata" Version="1.6.0" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="2.0.1" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/coverlet.msbuild.tasks/coverlet.msbuild.tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFrameworks>netcoreapp2.0;net472</TargetFrameworks>
<AssemblyVersion>2.4.0</AssemblyVersion>

<PackageId>coverlet.msbuild</PackageId>
Expand Down
3 changes: 3 additions & 0 deletions src/coverlet.msbuild/coverlet.msbuild.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
<Threshold Condition="$(Threshold) == ''">0</Threshold>
<ThresholdType Condition="$(ThresholdType) == ''">line,branch,method</ThresholdType>
<ThresholdStat Condition="$(ThresholdStat) == ''">minimum</ThresholdStat>

<CoverletBuildTaskPath Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)net472\</CoverletBuildTaskPath>
<CoverletBuildTaskPath Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)netcoreapp2.0\</CoverletBuildTaskPath>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions src/coverlet.msbuild/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)netcoreapp2.0\coverlet.msbuild.tasks.dll"/>
<UsingTask TaskName="Coverlet.MSbuild.Tasks.CoverageResultTask" AssemblyFile="$(MSBuildThisFileDirectory)netcoreapp2.0\coverlet.msbuild.tasks.dll"/>
<UsingTask TaskName="Coverlet.MSbuild.Tasks.InstrumentationTask" AssemblyFile="$(CoverletBuildTaskPath)coverlet.msbuild.tasks.dll"/>
<UsingTask TaskName="Coverlet.MSbuild.Tasks.CoverageResultTask" AssemblyFile="$(CoverletBuildTaskPath)coverlet.msbuild.tasks.dll"/>

<Target Name="InstrumentModulesNoBuild" BeforeTargets="VSTest">
<Coverlet.MSbuild.Tasks.InstrumentationTask
Expand Down
4 changes: 2 additions & 2 deletions src/coverlet.template/coverlet.template.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netcoreapp2.0;net472</TargetFrameworks>
</PropertyGroup>

</Project>

0 comments on commit 7235806

Please sign in to comment.