Skip to content

Commit f4aa259

Browse files
authored
Merge pull request #299 from sharwell/cleaner-build
Improve build tasks packaging
2 parents bb0a20f + 0aa1891 commit f4aa259

File tree

9 files changed

+69
-39
lines changed

9 files changed

+69
-39
lines changed

appveyor.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ test_script:
1616
chmod +x codecov
1717
./codecov -f ./test/coverlet.core.tests/coverage.opencover.xml
1818
}
19+
artifacts:
20+
- path: src\coverlet.msbuild.tasks\bin\Release\*.nupkg
21+
- path: build\Release\*.nupkg

build.proj

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

33
<PropertyGroup>
4-
<NuspecFile>$(MSBuildThisFileDirectory)coverlet.msbuild.nuspec</NuspecFile>
54
<Configuration Condition="$(Configuration) == ''">Debug</Configuration>
65
<OutputPath>$(MSBuildThisFileDirectory)build\$(Configuration)</OutputPath>
6+
7+
<!-- AppVeyor workaround for https://github.com/dotnet/sdk/issues/335 -->
8+
<TargetFrameworkOverride Condition="'$(APPVEYOR_BUILD_WORKER_IMAGE)' == 'Ubuntu'">-f netcoreapp2.0</TargetFrameworkOverride>
79
</PropertyGroup>
810

911
<Target Name="BuildAllProjects">
1012
<RemoveDir Directories="$(OutputPath)" Condition="Exists('$(MSBuildThisFileDirectory)\build')" />
11-
<Exec Command="dotnet build &quot;$(MSBuildThisFileDirectory)src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj&quot; -c $(Configuration)" />
13+
<Exec Command="dotnet build &quot;$(MSBuildThisFileDirectory)src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj&quot; -c $(Configuration) $(TargetFrameworkOverride)" />
1214
<Exec Command="dotnet build &quot;$(MSBuildThisFileDirectory)src\coverlet.console\coverlet.console.csproj&quot; -c $(Configuration)" />
1315
</Target>
1416

1517
<Target Name="PublishMSBuildTaskProject" AfterTargets="BuildAllProjects">
16-
<Exec Command="dotnet publish &quot;$(MSBuildThisFileDirectory)src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj&quot; -c $(Configuration) -o &quot;$(OutputPath)&quot;" />
18+
<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;" />
1719
</Target>
1820

1921
<Target Name="CopyMSBuildScripts" AfterTargets="PublishMSBuildTaskProject">
2022
<ItemGroup>
21-
<BuildScript Include="$(MSBuildThisFileDirectory)src\coverlet.msbuild\coverlet.msbuild.props" />
22-
<BuildScript Include="$(MSBuildThisFileDirectory)src\coverlet.msbuild\coverlet.msbuild.targets" />
23+
<BuildScript Include="$(MSBuildThisFileDirectory)src\coverlet.msbuild.tasks\coverlet.msbuild.props" />
24+
<BuildScript Include="$(MSBuildThisFileDirectory)src\coverlet.msbuild.tasks\coverlet.msbuild.targets" />
2325
</ItemGroup>
2426
<Copy SourceFiles="@(BuildScript)" DestinationFolder="$(OutputPath)" />
2527
</Target>
@@ -29,7 +31,6 @@
2931
</Target>
3032

3133
<Target Name="CreateNuGetPackage" AfterTargets="RunTests" Condition="$(Configuration) == 'Release'">
32-
<Exec Command="dotnet pack &quot;$(MSBuildThisFileDirectory)src\coverlet.msbuild.tasks\coverlet.msbuild.tasks.csproj&quot; -c $(Configuration) -o $(OutputPath) /p:NuspecFile=$(NuspecFile)" />
3334
<Exec Command="dotnet pack &quot;$(MSBuildThisFileDirectory)src\coverlet.console\coverlet.console.csproj&quot; -c $(Configuration) -o $(OutputPath)" />
3435
</Target>
3536

coverlet.msbuild.nuspec

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/coverlet.core/Coverage.cs

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

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

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

320321
if (relativePathOfBestMatch.Length == 0)
321322
{

src/coverlet.core/coverlet.core.csproj

Lines changed: 5 additions & 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>4.1.1</AssemblyVersion>
77
</PropertyGroup>
88

@@ -12,6 +12,10 @@
1212
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="2.0.1" />
1313
</ItemGroup>
1414

15+
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
16+
<PackageReference Include="System.Reflection.Metadata" Version="1.6.0" />
17+
</ItemGroup>
18+
1519
<ItemGroup>
1620
<ProjectReference Include="..\coverlet.template\coverlet.template.csproj" />
1721
</ItemGroup>

src/coverlet.msbuild/coverlet.msbuild.props renamed to src/coverlet.msbuild.tasks/coverlet.msbuild.props

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

src/coverlet.msbuild/coverlet.msbuild.targets renamed to 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="$(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

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

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,62 @@
22

33
<PropertyGroup>
44
<OutputType>Library</OutputType>
5-
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
<TargetFrameworks>netcoreapp2.0;net472</TargetFrameworks>
66
<AssemblyVersion>2.4.1</AssemblyVersion>
7+
8+
<PackageId>coverlet.msbuild</PackageId>
9+
<PackageVersion>2.5.1</PackageVersion>
10+
<Title>coverlet.msbuild</Title>
11+
<Authors>tonerdo</Authors>
12+
<PackageLicenseUrl>https://github.com/tonerdo/coverlet/blob/master/LICENSE</PackageLicenseUrl>
13+
<PackageProjectUrl>http://github.com/tonerdo/coverlet</PackageProjectUrl>
14+
<PackageIconUrl>https://raw.githubusercontent.com/tonerdo/coverlet/master/_assets/coverlet-icon.svg?sanitize=true</PackageIconUrl>
15+
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
16+
<DevelopmentDependency>true</DevelopmentDependency>
17+
<Description>Coverlet is a cross platform code coverage library for .NET Core, with support for line, branch and method coverage.</Description>
18+
<PackageTags>coverage testing unit-test lcov opencover quality</PackageTags>
19+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
20+
21+
<!-- Items in the Content group are placed in this folder in the NuGet package. -->
22+
<ContentTargetFolders>build</ContentTargetFolders>
23+
24+
<!-- Build tasks should not be added to the lib folder. -->
25+
<IncludeBuildOutput>false</IncludeBuildOutput>
26+
<IncludeSymbols>true</IncludeSymbols>
27+
<IncludeSources>true</IncludeSources>
28+
29+
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
30+
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);PackBuildOutputs</TargetsForTfmSpecificContentInPackage>
731
</PropertyGroup>
832

933
<ItemGroup>
10-
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.5.180" />
34+
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.5.180" PrivateAssets="All" />
1135
</ItemGroup>
1236

1337
<ItemGroup>
14-
<ProjectReference Include="$(MSBuildThisFileDirectory)..\coverlet.core\coverlet.core.csproj" />
38+
<ProjectReference Include="$(MSBuildThisFileDirectory)..\coverlet.core\coverlet.core.csproj" PrivateAssets="All" />
1539
</ItemGroup>
1640

1741
<ItemGroup>
1842
<Compile Include="..\coverlet.console\ConsoleTables\ConsoleTable.cs" Link="ConsoleTables\ConsoleTable.cs" />
1943
</ItemGroup>
2044

45+
<ItemGroup>
46+
<Content Include="coverlet.msbuild.props" />
47+
<Content Include="coverlet.msbuild.targets" />
48+
</ItemGroup>
49+
50+
<Target Name="PackBuildOutputs" DependsOnTargets="ResolveProjectReferences;SatelliteDllsProjectOutputGroup;DebugSymbolsProjectOutputGroup;SatelliteDllsProjectOutputGroupDependencies;ResolveAssemblyReferences">
51+
<ItemGroup>
52+
<TfmSpecificPackageFile Include="$(TargetPath)" PackagePath="build\$(TargetFramework)\" />
53+
<TfmSpecificPackageFile Include="$(DepsFilePath)" PackagePath="build\$(TargetFramework)\" />
54+
<TfmSpecificPackageFile Include="@(DebugSymbolsProjectOutputGroupOutput)" PackagePath="build\$(TargetFramework)\" />
55+
<!--<TfmSpecificPackageFile Include="@(SatelliteDllsProjectOutputGroupDependency)" PackagePath="build\$(TargetFramework)\%(SatelliteDllsProjectOutputGroupDependency.DestinationSubDirectory)" />-->
56+
<!--<TfmSpecificPackageFile Include="@(SatelliteDllsProjectOutputGroupOutput->'%(FinalOutputPath)')" PackagePath="build\$(TargetFramework)\%(SatelliteDllsProjectOutputGroupOutput.Culture)\" />-->
57+
<TfmSpecificPackageFile Include="%(_ResolvedProjectReferencePaths.Identity)" PackagePath="build\$(TargetFramework)\" />
58+
59+
<TfmSpecificPackageFile Include="@(ReferenceCopyLocalPaths)" Exclude="@(_ResolvedProjectReferencePaths)" PackagePath="build\$(TargetFramework)\%(ReferenceCopyLocalPaths.DestinationSubPath)" />
60+
</ItemGroup>
61+
</Target>
62+
2163
</Project>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<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)