Skip to content
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

Move/Pin to 3.1 runtime #688

Merged
merged 14 commits into from
Jan 14, 2020
Binary file added _assets/coverlet-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 8 additions & 3 deletions eng/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
steps:
- task: UseDotNet@2
inputs:
version: 2.2.402
version: 2.2.207
Copy link
Collaborator Author

@MarcoRossignoli MarcoRossignoli Jan 13, 2020

Choose a reason for hiding this comment

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

we have some integration tests done with netcoreapp2.1;netcoreapp2.2 and roll forward major is not supported by default https://github.com/dotnet/designs/blob/master/accepted/runtime-binding.md

displayName: Install .NET Core SDK

- task: UseDotNet@2
inputs:
version: 3.1.100
displayName: Install .NET Core SDK

- script: dotnet restore
Expand All @@ -10,12 +15,12 @@ steps:
- script: dotnet build -c $(BuildConfiguration) --no-restore
displayName: Build

- script: dotnet pack -c $(BuildConfiguration) --no-build
- script: dotnet pack -c $(BuildConfiguration)
displayName: Pack

- task: DotNetCoreCLI@2
displayName: Test
inputs:
command: test
arguments: -c $(BuildConfiguration) --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Include=[coverlet.*]* /p:Exclude=[coverlet.tests.remoteexecutor]*
testRunTitle: $(Agent.JobName)
testRunTitle: $(Agent.JobName)
8 changes: 4 additions & 4 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.2.402"
}
}
"sdk": {
"version": "3.1.100"
}
}
26 changes: 19 additions & 7 deletions src/coverlet.collector/coverlet.collector.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk" >
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<AssemblyTitle>coverlet.collector</AssemblyTitle>
<PackageId>coverlet.collector</PackageId>
<DevelopmentDependency>true</DevelopmentDependency>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<IncludeBuildOutput>false</IncludeBuildOutput>
<!--
suppress warning https://docs.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu5128
If your package does not contain any lib/ or ref/ files and is not a meta-package,
it likely does not have any dependencies that the package consumer needs.
If you are packing with NuGet's MSBuild Pack target, you can set <SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking> in any PropertyGroup in your project file.
-->
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);PackBuildOutputs</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>

<!-- Nuget package properties https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets -->
<PropertyGroup>
<Title>coverlet.collector</Title>
<PackageId>coverlet.collector</PackageId>
<Authors>tonerdo</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>http://github.com/tonerdo/coverlet</PackageProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/tonerdo/coverlet/master/_assets/coverlet-icon.svg?sanitize=true</PackageIconUrl>
<PackageIcon>coverlet-icon.png</PackageIcon>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<DevelopmentDependency>true</DevelopmentDependency>
<Description>Coverlet is a cross platform code coverage library for .NET, with support for line, branch and method coverage.</Description>
<PackageTags>coverage testing unit-test lcov opencover quality</PackageTags>
<RepositoryType>git</RepositoryType>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<IncludeBuildOutput>false</IncludeBuildOutput>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);PackBuildOutputs</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>

<ItemGroup>
Expand All @@ -25,6 +36,7 @@

<ItemGroup>
<None Update="build\**" Pack="true" PackagePath="" />
<None Include="..\..\_assets\coverlet-icon.png" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 11 additions & 2 deletions src/coverlet.console/coverlet.console.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<ToolCommandName>coverlet</ToolCommandName>
<PackAsTool>true</PackAsTool>
<AssemblyTitle>coverlet.console</AssemblyTitle>
<Authors>tonerdo</Authors>
</PropertyGroup>

<!-- Nuget package properties https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets -->
<PropertyGroup>
<PackageId>$(AssemblyTitle)</PackageId>
<Authors>tonerdo</Authors>
<Description>Coverlet is a cross platform code coverage tool for .NET, with support for line, branch and method coverage.</Description>
<PackageTags>coverage;testing;unit-test;lcov;opencover;quality</PackageTags>
<PackageIconUrl>https://raw.githubusercontent.com/tonerdo/coverlet/master/_assets/coverlet-icon.svg?sanitize=true</PackageIconUrl>
<PackageIcon>coverlet-icon.png</PackageIcon>
<PackageProjectUrl>https://github.com/tonerdo/coverlet</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
Expand All @@ -24,4 +29,8 @@
<ProjectReference Include="$(MSBuildThisFileDirectory)..\coverlet.core\coverlet.core.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\_assets\coverlet-icon.png" Pack="true" PackagePath="\"/>
</ItemGroup>

</Project>
24 changes: 20 additions & 4 deletions src/coverlet.msbuild.tasks/coverlet.msbuild.tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,33 @@
<OutputType>Library</OutputType>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyTitle>coverlet.msbuild.tasks</AssemblyTitle>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);PackBuildOutputs</TargetsForTfmSpecificContentInPackage>
<ContentTargetFolders>build</ContentTargetFolders>
<IncludeBuildOutput>false</IncludeBuildOutput>
<!--
suppress warning https://docs.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu5128
If your package does not contain any lib/ or ref/ files and is not a meta-package,
it likely does not have any dependencies that the package consumer needs.
If you are packing with NuGet's MSBuild Pack target, you can set <SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking> in any PropertyGroup in your project file.
-->
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
</PropertyGroup>

<!-- Nuget package properties https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets -->
<PropertyGroup>
<PackageId>coverlet.msbuild</PackageId>
<Title>coverlet.msbuild</Title>
<Authors>tonerdo</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>http://github.com/tonerdo/coverlet</PackageProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/tonerdo/coverlet/master/_assets/coverlet-icon.svg?sanitize=true</PackageIconUrl>
<PackageIcon>coverlet-icon.png</PackageIcon>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<DevelopmentDependency>true</DevelopmentDependency>
<Description>Coverlet is a cross platform code coverage library for .NET, with support for line, branch and method coverage.</Description>
<PackageTags>coverage testing unit-test lcov opencover quality</PackageTags>
<RepositoryType>git</RepositoryType>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);PackBuildOutputs</TargetsForTfmSpecificContentInPackage>
<ContentTargetFolders>build</ContentTargetFolders>
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>

<ItemGroup>
Expand All @@ -38,6 +50,10 @@
<Content Include="coverlet.msbuild.targets" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\_assets\coverlet-icon.png" Pack="true" PackagePath="\" />
</ItemGroup>

<Target Name="PackBuildOutputs" DependsOnTargets="ResolveProjectReferences;SatelliteDllsProjectOutputGroup;DebugSymbolsProjectOutputGroup;SatelliteDllsProjectOutputGroupDependencies;ResolveAssemblyReferences">
<ItemGroup>
<TfmSpecificPackageFile Include="$(TargetPath)" PackagePath="build\" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="$(RepoRoot)src\coverlet.msbuild.tasks\coverlet.msbuild.props" />

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<LangVersion>preview</LangVersion>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="$(RepoRoot)src\coverlet.msbuild.tasks\coverlet.msbuild.props" />

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public void TestInstrument_ExcludedFilesHelper(string[] excludeFilterHelper, Val
[Fact]
public void SkipEmbeddedPpdbWithoutLocalSource()
{
string xunitDll = Directory.GetFiles(Directory.GetCurrentDirectory(), "xunit.*.dll").First();
string xunitDll = Directory.GetFiles(Directory.GetCurrentDirectory(), "xunit.core.dll").First();
var loggerMock = new Mock<ILogger>();
Instrumenter instrumenter = new Instrumenter(xunitDll, "_xunit_instrumented", Array.Empty<string>(), Array.Empty<string>(), Array.Empty<string>(), Array.Empty<string>(), false, loggerMock.Object, _instrumentationHelper, new FileSystem());
Assert.True(_instrumentationHelper.HasPdb(xunitDll, out bool embedded));
Expand Down
2 changes: 1 addition & 1 deletion test/coverlet.core.tests/coverlet.core.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="$(RepoRoot)src\coverlet.msbuild.tasks\coverlet.msbuild.props" />

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<LangVersion>preview</LangVersion>
<NoWarn>$(NoWarn);CS8002</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<AssemblyName>coverletsamplelib.integration.template</AssemblyName>
</PropertyGroup>
Expand Down
29 changes: 24 additions & 5 deletions test/coverlet.integration.tests/BaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public abstract class BaseTest
private BuildConfiguration GetAssemblyBuildConfiguration()
{
var configurationAttribute = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyConfigurationAttribute>();

if (configurationAttribute is null)
{
throw new ArgumentNullException("AssemblyConfigurationAttribute not found");
}

if (configurationAttribute.Configuration.Equals("Debug", StringComparison.InvariantCultureIgnoreCase))
{
return BuildConfiguration.Debug;
Expand Down Expand Up @@ -260,6 +266,11 @@ private protected void UpdateProjectTargetFramework(ClonedTemplateProject projec

private protected void PinSDK(ClonedTemplateProject project, string sdkVersion)
{
if (project is null)
{
throw new ArgumentNullException(nameof(project));
}

if (string.IsNullOrEmpty(sdkVersion))
{
throw new ArgumentException("Invalid sdkVersion", nameof(sdkVersion));
Expand All @@ -270,23 +281,31 @@ private protected void PinSDK(ClonedTemplateProject project, string sdkVersion)
throw new FileNotFoundException("coverlet.integration.template.csproj not found", "coverlet.integration.template.csproj");
}

if (project.ProjectRootPath is null || Directory.Exists(project.ProjectRootPath))
{
throw new ArgumentException("Invalid ProjectRootPath");
}

File.WriteAllText(Path.Combine(project.ProjectRootPath, "global.json"), $"{{ \"sdk\": {{ \"version\": \"{sdkVersion}\" }} }}");
}
}

class ClonedTemplateProject : IDisposable
{
private bool _cleanupOnDispose;

public string? ProjectRootPath { get; private set; }
public string ProjectRootPath { get; private set; }
public bool CleanupOnDispose { get; private set; }

// We need to have a different asm name to avoid issue with collectors, we filter [coverlet.*]* by default
// https://github.com/tonerdo/coverlet/pull/410#discussion_r284526728
public static string AssemblyName { get; } = "coverletsamplelib.integration.template";
public static string ProjectFileName { get; } = "coverlet.integration.template.csproj";
public string ProjectFileNamePath => Path.Combine(ProjectRootPath, "coverlet.integration.template.csproj");

public ClonedTemplateProject(string projectRootPath, bool cleanupOnDispose) => (ProjectRootPath, _cleanupOnDispose) = (projectRootPath, cleanupOnDispose);
public ClonedTemplateProject(string? projectRootPath, bool cleanupOnDispose)
{
ProjectRootPath = (projectRootPath ?? throw new ArgumentNullException(nameof(projectRootPath)));
CleanupOnDispose = cleanupOnDispose;
}

public bool IsMultipleTargetFramework()
{
Expand Down Expand Up @@ -314,7 +333,7 @@ public string[] GetFiles(string filter)

public void Dispose()
{
if (_cleanupOnDispose)
if (CleanupOnDispose)
{
Directory.Delete(ProjectRootPath, true);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<IsTestProject>false</IsTestProject>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>Coverlet.Tests.RemoteExecutor</RootNamespace>
<IsPackable>false</IsPackable>
<IsTestProject>false</IsTestProject>
Expand Down
2 changes: 1 addition & 1 deletion test/coverlet.testsubject/coverlet.testsubject.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<IsTestProject>false</IsTestProject>
</PropertyGroup>
Expand Down