Skip to content

Improve build tasks packaging #299

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 9 commits into from
Mar 1, 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
3 changes: 3 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ test_script:
chmod +x codecov
./codecov -f ./test/coverlet.core.tests/coverage.opencover.xml
}
artifacts:
- path: src\coverlet.msbuild.tasks\bin\Release\*.nupkg
- path: build\Release\*.nupkg
13 changes: 7 additions & 6 deletions build.proj
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<NuspecFile>$(MSBuildThisFileDirectory)coverlet.msbuild.nuspec</NuspecFile>
<Configuration Condition="$(Configuration) == ''">Debug</Configuration>
<OutputPath>$(MSBuildThisFileDirectory)build\$(Configuration)</OutputPath>

<!-- AppVeyor workaround for https://github.com/dotnet/sdk/issues/335 -->
<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)&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">
<ItemGroup>
<BuildScript Include="$(MSBuildThisFileDirectory)src\coverlet.msbuild\coverlet.msbuild.props" />
<BuildScript Include="$(MSBuildThisFileDirectory)src\coverlet.msbuild\coverlet.msbuild.targets" />
<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>
Expand All @@ -29,7 +31,6 @@
</Target>

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

Expand Down
24 changes: 0 additions & 24 deletions coverlet.msbuild.nuspec

This file was deleted.

5 changes: 3 additions & 2 deletions src/coverlet.core/Coverage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is indeed a functional workaround to using Path.GetRelativePath then we can make coverlet.msbuild be fully compliant with netcoreapp2.0 and net472 frameworks by making it target netstandard2.0 instead

Copy link
Collaborator

@tonerdo tonerdo Feb 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To my knowledge Coverlet worked quite well with net472 when the target was netstandard2.0. Only got issues when I changed it to netcoreapp2.0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is even working with net35

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sharwell are you still able to this? If not, I'll just merge it in and make the necessary changes if that's alright with you

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your help so far

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tonerdo I wanted to merge this one like this, then update and merge #301, and only then start to focus on enabling .NET Framework scenarios. Currently testing for the latter is completely blocked so I can't say for sure what will or will not work.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if it gets done in this PR. #301 might take a bit to get through and I want the next release (which I want to happen this week) to fix the .NET Framework issue

Copy link
Contributor Author

@sharwell sharwell Mar 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I'll have time to make and test this modification. I'll try to get it done tomorrow morning though (produce one netstandard2.0 assembly, which is included twice in the resulting package under two different paths).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries. I'll go ahead and merge this and effect the necessary changes. Thank you so much for all your work on this


if (relativePathOfBestMatch.Length == 0)
{
Expand Down
6 changes: 5 additions & 1 deletion src/coverlet.core/coverlet.core.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>4.1.1</AssemblyVersion>
</PropertyGroup>

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

<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<PackageReference Include="System.Reflection.Metadata" Version="1.6.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\coverlet.template\coverlet.template.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,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>
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="$(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
48 changes: 45 additions & 3 deletions src/coverlet.msbuild.tasks/coverlet.msbuild.tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,62 @@

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

<PackageId>coverlet.msbuild</PackageId>
<PackageVersion>2.5.1</PackageVersion>
<Title>coverlet.msbuild</Title>
<Authors>tonerdo</Authors>
<PackageLicenseUrl>https://github.com/tonerdo/coverlet/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>http://github.com/tonerdo/coverlet</PackageProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/tonerdo/coverlet/master/_assets/coverlet-icon.svg?sanitize=true</PackageIconUrl>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<DevelopmentDependency>true</DevelopmentDependency>
<Description>Coverlet is a cross platform code coverage library for .NET Core, with support for line, branch and method coverage.</Description>
<PackageTags>coverage testing unit-test lcov opencover quality</PackageTags>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

<!-- Items in the Content group are placed in this folder in the NuGet package. -->
<ContentTargetFolders>build</ContentTargetFolders>

<!-- Build tasks should not be added to the lib folder. -->
<IncludeBuildOutput>false</IncludeBuildOutput>
<IncludeSymbols>true</IncludeSymbols>
<IncludeSources>true</IncludeSources>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we're including symbols and sources?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can improve the debugging experience if needed. We can alter the way this is included in a future PR if desired.


<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);PackBuildOutputs</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.5.180" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.5.180" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)..\coverlet.core\coverlet.core.csproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)..\coverlet.core\coverlet.core.csproj" PrivateAssets="All" />
</ItemGroup>

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

<ItemGroup>
<Content Include="coverlet.msbuild.props" />
<Content Include="coverlet.msbuild.targets" />
</ItemGroup>

<Target Name="PackBuildOutputs" DependsOnTargets="ResolveProjectReferences;SatelliteDllsProjectOutputGroup;DebugSymbolsProjectOutputGroup;SatelliteDllsProjectOutputGroupDependencies;ResolveAssemblyReferences">
<ItemGroup>
<TfmSpecificPackageFile Include="$(TargetPath)" PackagePath="build\$(TargetFramework)\" />
<TfmSpecificPackageFile Include="$(DepsFilePath)" PackagePath="build\$(TargetFramework)\" />
<TfmSpecificPackageFile Include="@(DebugSymbolsProjectOutputGroupOutput)" PackagePath="build\$(TargetFramework)\" />
<!--<TfmSpecificPackageFile Include="@(SatelliteDllsProjectOutputGroupDependency)" PackagePath="build\$(TargetFramework)\%(SatelliteDllsProjectOutputGroupDependency.DestinationSubDirectory)" />-->
<!--<TfmSpecificPackageFile Include="@(SatelliteDllsProjectOutputGroupOutput->'%(FinalOutputPath)')" PackagePath="build\$(TargetFramework)\%(SatelliteDllsProjectOutputGroupOutput.Culture)\" />-->
<TfmSpecificPackageFile Include="%(_ResolvedProjectReferencePaths.Identity)" PackagePath="build\$(TargetFramework)\" />

<TfmSpecificPackageFile Include="@(ReferenceCopyLocalPaths)" Exclude="@(_ResolvedProjectReferencePaths)" PackagePath="build\$(TargetFramework)\%(ReferenceCopyLocalPaths.DestinationSubPath)" />
</ItemGroup>
</Target>

</Project>
2 changes: 1 addition & 1 deletion 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">

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

</Project>