diff --git a/build/Tasks/CodeCoverage.cs b/build/Tasks/CodeCoverage.cs new file mode 100644 index 0000000000..c6c7f8488d --- /dev/null +++ b/build/Tasks/CodeCoverage.cs @@ -0,0 +1,41 @@ +using System.Linq; +using Cake.Common; +using Cake.Common.Diagnostics; +using Cake.Core.IO; +using Cake.Coverlet; +using Cake.Frosting; + +[Dependency(typeof(Build))] +public sealed class CodeCoverage : FrostingTask +{ + public override void Run(Context context) + { + foreach (var project in context.Projects.Where(x => x.UnitTests)) + { + context.Information("Executing Code Coverage Project {0}...", project.Name); + var dotNetCoreTestSettings = context.GetTestSettings(); + dotNetCoreTestSettings.Framework = "netcoreapp2.0"; + + context.DotNetCoreTest(project.Path.FullPath, dotNetCoreTestSettings, new CoverletSettings() + { + CollectCoverage = true, + CoverletOutputFormat = CoverletOutputFormat.opencover, + CoverletOutputDirectory = DirectoryPath.FromString(@".\coverage-results\"), + CoverletOutputName = $"{project.Name}-netcoreapp2.0" + }); + + if (context.IsRunningOnWindows()) + { + dotNetCoreTestSettings.Framework = "net452"; + + context.DotNetCoreTest(project.Path.FullPath, dotNetCoreTestSettings, new CoverletSettings() + { + CollectCoverage = true, + CoverletOutputFormat = CoverletOutputFormat.opencover, + CoverletOutputDirectory = DirectoryPath.FromString(@".\coverage-results\"), + CoverletOutputName = $"{project.Name}-net452.0" + }); + } + } + } +} \ No newline at end of file diff --git a/build/Tasks/UnitTests.cs b/build/Tasks/UnitTests.cs index 00c682e76b..42584c642a 100644 --- a/build/Tasks/UnitTests.cs +++ b/build/Tasks/UnitTests.cs @@ -1,8 +1,6 @@ using System.Linq; using Cake.Common.Diagnostics; using Cake.Common.Tools.DotNetCore; -using Cake.Core.IO; -using Cake.Coverlet; using Cake.Frosting; [Dependency(typeof(Build))] @@ -16,26 +14,4 @@ public override void Run(Context context) context.DotNetCoreTest(project.Path.FullPath, context.GetTestSettings()); } } -} - -[Dependency(typeof(Build))] -public sealed class CodeCoverage : FrostingTask -{ - public override void Run(Context context) - { - foreach (var project in context.Projects.Where(x => x.UnitTests)) - { - context.Information("Executing Code Coverage Project {0}...", project.Name); - var dotNetCoreTestSettings = context.GetTestSettings(); - dotNetCoreTestSettings.Framework = "netcoreapp2.0"; - - context.DotNetCoreTest(project.Path.FullPath, dotNetCoreTestSettings, new CoverletSettings() - { - CollectCoverage = true, - CoverletOutputFormat = CoverletOutputFormat.opencover, - CoverletOutputDirectory = DirectoryPath.FromString(@".\coverage-results\"), - CoverletOutputName = $"{project.Name}" - }); - } - } } \ No newline at end of file