diff --git a/.build/Build.cs b/.build/Build.cs
index 3e0702b2..6ff88273 100644
--- a/.build/Build.cs
+++ b/.build/Build.cs
@@ -27,11 +27,11 @@ class Solution : DotNetCoreBuild, IDotNetCoreBuild
.DependsOn(Pack)
;
- public new Target Restore => _ => _.With(DotNetCoreBuild.Restore, this);
+ public new Target Restore => _ => _.With(this, DotNetCoreBuild.Restore);
- public new Target Build => _ => _.With(DotNetCoreBuild.Build, this);
+ public new Target Build => _ => _.With(this, DotNetCoreBuild.Build);
- public new Target Test => _ => _.With(DotNetCoreBuild.Test, this);
+ public new Target Test => _ => _.With(this, DotNetCoreBuild.Test);
- public new Target Pack => _ => _.With(DotNetCoreBuild.Pack, this);
+ public new Target Pack => _ => _.With(this, DotNetCoreBuild.Pack);
}
diff --git a/src/Nuke.DotNetCore/DotNetCoreBuild.cs b/src/Nuke.DotNetCore/DotNetCoreBuild.cs
index e375d238..7bd42bf4 100644
--- a/src/Nuke.DotNetCore/DotNetCoreBuild.cs
+++ b/src/Nuke.DotNetCore/DotNetCoreBuild.cs
@@ -12,6 +12,7 @@
using System.IO;
using System.Linq;
using System;
+using Nuke.Common.Tooling;
namespace Rocket.Surgery.Nuke.DotNetCore
{
@@ -65,36 +66,69 @@ public static ITargetDefinition Build(ITargetDefinition _, IDotNetCoreBuild buil
///
/// dotnet test
///
- public static ITargetDefinition Test(ITargetDefinition _, IDotNetCoreBuild build) => _
- .Description("Executes all the unit tests.")
- .After(build.Build)
- .DependentFor(build.Pack)
- .DependentFor(build.Generate_Code_Coverage_Reports)
- .Triggers(build.Generate_Code_Coverage_Reports)
- .OnlyWhenStatic(() => DirectoryExists(build.TestDirectory))
- .OnlyWhenDynamic(() => build.TestDirectory.GlobFiles("**/*.csproj").Count > 0)
- .WhenSkipped(DependencyBehavior.Execute)
- .Executes(async () =>
- {
- DotNetTest(s => s
- .SetProjectFile(build.Solution)
- .SetDefaultLoggers(build.LogsDirectory / "test.log")
- .SetGitVersionEnvironment(build.GitVersion)
- .SetConfiguration("Debug")
- .EnableNoRestore()
- .SetLogger($"trx")
- .SetProperty("CollectCoverage", "true")
- // DeterministicSourcePaths being true breaks coverlet!
- .SetProperty("DeterministicSourcePaths", "false")
- .SetProperty("CoverageDirectory", build.CoverageDirectory)
- .SetResultsDirectory(build.TestResultsDirectory)
- );
+ public static ITargetDefinition Test(ITargetDefinition _, IDotNetCoreBuild build) => Test(true)(_, build);
- foreach (var coverage in build.TestResultsDirectory.GlobFiles("**/*.cobertura.xml"))
- {
- CopyFileToDirectory(coverage, build.CoverageDirectory, FileExistsPolicy.OverwriteIfNewer);
- }
- });
+ ///
+ /// dotnet test
+ ///
+ public static Func Test(bool useDataCollector) =>
+ (ITargetDefinition _, IDotNetCoreBuild build) => _
+ .Description("Executes all the unit tests.")
+ .After(build.Build)
+ .DependentFor(build.Pack)
+ .DependentFor(build.Generate_Code_Coverage_Reports)
+ .Triggers(build.Generate_Code_Coverage_Reports)
+ .OnlyWhenStatic(() => DirectoryExists(build.TestDirectory))
+ .OnlyWhenDynamic(() => build.TestDirectory.GlobFiles("**/*.csproj").Count > 0)
+ .WhenSkipped(DependencyBehavior.Execute)
+ .Executes(() => EnsureCleanDirectory(build.TestResultsDirectory))
+ .Executes(async () =>
+ {
+ var runsettings = build.TestDirectory / "coverlet.runsettings";
+ if (!FileExists(runsettings))
+ {
+ runsettings = TemporaryDirectory / "default.runsettings";
+ if (!FileExists(runsettings))
+ {
+ using var tempFile = File.Open(runsettings, FileMode.CreateNew);
+ await typeof(DotNetCoreBuild).Assembly
+ .GetManifestResourceStream("Rocket.Surgery.Nuke.default.runsettings")!
+ .CopyToAsync(tempFile)
+ .ConfigureAwait(false);
+ }
+ }
+
+ DotNetTest(s => s
+ .SetProjectFile(build.Solution)
+ .SetDefaultLoggers(build.LogsDirectory / "test.log")
+ .SetGitVersionEnvironment(build.GitVersion)
+ .SetConfiguration("Debug")
+ .EnableNoRestore()
+ .SetLogger($"trx")
+ // DeterministicSourcePaths being true breaks coverlet!
+ .SetProperty("DeterministicSourcePaths", "false")
+ .SetResultsDirectory(build.TestResultsDirectory)
+ .When(useDataCollector, x => x
+ .SetProperty("CollectCoverage", "true")
+ .SetProperty("CoverageDirectory", build.CoverageDirectory)
+ )
+ .When(!useDataCollector, x => x
+ .SetProperty("CollectCoverage", "false")
+ .SetDataCollector("XPlat Code Coverage")
+ .SetSettingsFile(runsettings)
+ )
+ );
+
+ foreach (var coverage in build.TestResultsDirectory.GlobFiles("**/*.cobertura.xml"))
+ {
+ CopyDirectoryRecursively(
+ Path.GetDirectoryName(coverage),
+ build.CoverageDirectory,
+ DirectoryExistsPolicy.Merge,
+ FileExistsPolicy.OverwriteIfNewer
+ );
+ }
+ });
///
/// dotnet pack
diff --git a/src/Nuke.DotNetCore/Rocket.Surgery.Nuke.DotNetCore.csproj b/src/Nuke.DotNetCore/Rocket.Surgery.Nuke.DotNetCore.csproj
index a2ac9b3f..fdfd22da 100644
--- a/src/Nuke.DotNetCore/Rocket.Surgery.Nuke.DotNetCore.csproj
+++ b/src/Nuke.DotNetCore/Rocket.Surgery.Nuke.DotNetCore.csproj
@@ -11,6 +11,7 @@
+
diff --git a/src/Nuke.DotNetCore/default.runsettings b/src/Nuke.DotNetCore/default.runsettings
new file mode 100644
index 00000000..33d98637
--- /dev/null
+++ b/src/Nuke.DotNetCore/default.runsettings
@@ -0,0 +1,14 @@
+
+
+
+
+
+ json,lcov,cobertura,opencover
+ [Bogus*]*,[Autofac*]*,[FakeItEasy*]*,[Moq*]*,[xunit*]*,[Microsoft.*]*,[XunitXml*]*,[coverlet.*]*,[System.*]*,[*]JetBrains.Annotations*
+
+ Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Nuke.Xamarin/XamarinConfiguration.cs b/src/Nuke.Xamarin/XamarinConfiguration.cs
index 4efbe5ae..6c159fcf 100644
--- a/src/Nuke.Xamarin/XamarinConfiguration.cs
+++ b/src/Nuke.Xamarin/XamarinConfiguration.cs
@@ -11,7 +11,6 @@ namespace Rocket.Surgery
///
/// Represents xamarin build configuration.
///
- [PublicAPI]
[TypeConverter(typeof(TypeConverter))]
public class XamarinConfiguration : Enumeration
{
diff --git a/src/Nuke/LoggingExtensions.cs b/src/Nuke/LoggingExtensions.cs
index cab91d1d..ffe9134e 100644
--- a/src/Nuke/LoggingExtensions.cs
+++ b/src/Nuke/LoggingExtensions.cs
@@ -5,26 +5,37 @@
namespace Rocket.Surgery.Nuke
{
+ ///
public static class LoggingExtensions
{
+ ///
public static void Log(string log) => Logger.Normal(log);
- public static void Debug(string info) { Logger.Trace(info); }
+ ///
+ public static void Debug(string info) => Logger.Trace(info);
- public static void Debug(string info, params object[] args) { Logger.Trace(info, args); }
+ ///
+ public static void Debug(string info, params object[] args) => Logger.Trace(info, args);
- public static void Information(string info) { Logger.Info(info); }
+ ///
+ public static void Information(string info) => Logger.Info(info);
- public static void Information(string info, params object[] args) { Logger.Info(info, args); }
+ ///
+ public static void Information(string info, params object[] args) => Logger.Info(info, args);
- public static void Warning(string info) { Logger.Warn(info); }
+ ///
+ public static void Warning(string info) => Logger.Warn(info);
- public static void Warning(string info, params object[] args) { Logger.Warn(info, args); }
+ ///
+ public static void Warning(string info, params object[] args) => Logger.Warn(info, args);
- public static void Error(string info) { Logger.Error(info); }
+ ///
+ public static void Error(string info) => Logger.Error(info);
- public static void Error(string info, params object[] args) { Logger.Error(info, args); }
+ ///
+ public static void Error(string info, params object[] args) => Logger.Error(info, args);
- public static string EnvironmentVariable(string key) => Environment.GetEnvironmentVariable(key);
+ ///
+ public static string? EnvironmentVariable(string key) => Environment.GetEnvironmentVariable(key);
}
}
diff --git a/src/Nuke/NuGetVerbosityMappingAttribute.cs b/src/Nuke/NuGetVerbosityMappingAttribute.cs
index 68942919..13ff900a 100644
--- a/src/Nuke/NuGetVerbosityMappingAttribute.cs
+++ b/src/Nuke/NuGetVerbosityMappingAttribute.cs
@@ -12,6 +12,7 @@ namespace Rocket.Surgery.Nuke
///
/// Mapping for nuget Verbosity
///
+ [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class NuGetVerbosityMappingAttribute : VerbosityMappingAttribute
{
///
diff --git a/src/Nuke/PackageIconAttribute.cs b/src/Nuke/PackageIconAttribute.cs
index 8be8df51..b83a44c1 100644
--- a/src/Nuke/PackageIconAttribute.cs
+++ b/src/Nuke/PackageIconAttribute.cs
@@ -17,7 +17,7 @@ public sealed class PackageIconAttribute : DownloadFileAttribute
///
/// The Url to download
/// The file path to download to, defaults to TemporaryDirectory / packageicon.[ext]
- public PackageIconAttribute(string url, string filePath = null)
+ public PackageIconAttribute(string url, string? filePath = null)
: base(url, filePath == null ? ("packageicon" + System.IO.Path.GetExtension(url)) : (AbsolutePath)filePath)
{
Type = "Package Icon";
diff --git a/src/Nuke/Readme/IMarkdownReferences.cs b/src/Nuke/Readme/IMarkdownReferences.cs
index 09a5d4e4..0bf5b078 100644
--- a/src/Nuke/Readme/IMarkdownReferences.cs
+++ b/src/Nuke/Readme/IMarkdownReferences.cs
@@ -13,6 +13,6 @@ public interface IMarkdownReferences
///
///
///
- string AddReference(string name, string value, string altText = null);
+ string AddReference(string name, string value, string? altText = null);
}
}
diff --git a/src/Nuke/Readme/NugetPackagesSection.cs b/src/Nuke/Readme/NugetPackagesSection.cs
index b8907900..0579a2e0 100644
--- a/src/Nuke/Readme/NugetPackagesSection.cs
+++ b/src/Nuke/Readme/NugetPackagesSection.cs
@@ -50,9 +50,9 @@ public string GetResult(IDictionary config, IMarkdownReferences
var dcfg = config;
var myget = dcfg["myget"] as IDictionary