diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 4903ba5f5b..3016fc72c1 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "cake.tool": { - "version": "1.3.0", + "version": "2.0.0-rc0001", "commands": [ "dotnet-cake" ] diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 494833b3fd..fc0fd08e39 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,3 +1,138 @@ +### New in 2.0.0-rc0002 (Released 2021/11/26) + +* 3714 Use Basic.Reference.Assemblies.* to ensure all standard reference assemblies are available for Roslyn +* 3654 IsRunningOnAzurePipelines should ignore agent type +* 3631 Refactor GitHub Actions Paths +* 3610 Remove TFBuildProvider +* 3590 Directories in AzurePipelinesBuildInfo are FilePaths - FilePath.GetDirectory then inconsistent +* 3581 Stop shipping Cake.Portable Chocolatey package and Cake Homebrew formulae +* 3579 Stop shipping Cake runner for .NET Framework and Cake runner for .NET Core +* 3577 Remove ReverseDependencyAttribute +* 3572 Only build for TargetFrameworks netcoreapp3.1, net5.0 and net6.0 +* 3282 GitVersion Tool: Rename verbosity values to match GitVersion values +* 3222 Add Xamarin.iOS platform targets to MSBuildSettings PlatformTarget enumeration +* 3151 Add support for Engine event hooks after execution as well as before +* 3003 Remove DependencyAttribute +* 2872 Bump eol target frameworks +* 2788 Tool:OpenCover - the register-setting should be an option, rather than a string +* 1111 DotNetCoreRestore: dotnet restore no longer supports globbing +* 3630 Add GitHub Actions Environment properties +* 3629 Add GitHub Actions UploadArtifact Command +* 3628 Add GitHub Actions SetEnvironmentVariable Command +* 3627 Add GitHub Actions AddPath Command +* 3341 Epic: Introduce DotNet aliases (synonyms to DotNetCore aliases) +* 3711 SemanticVersion missing equals/not equals operator, prerelease sorted wrong +* 3697 Error: The requested service 'Cake.Commands.DefaultCommandSettings' has not been registered +* 3693 `Core` suffix is still used in some settings classes +* 3683 Use DotNetMSBuildSettings instead of DotNetCoreMSBuildSettings on new dotnet aliases settings +* 3671 VS2022: msbuild can not be located, only Build Tools are installed +* 2443 Erroneous "Target path must be an absolute path" when preserveFolderStructure is used with CopyFiles +* 1669 Release notes does not tolerate prerelease versions +* 3709 Arguments alias should support ICollection as default value +* 3691 Update Microsoft.NETCore.Platforms to 6.0.0 +* 3690 Update Microsoft.Extensions.DependencyInjection to 6.0.0 +* 3689 Update System.Reflection.Metadata to 6.0.0 +* 3688 Update System.Collections.Immutable to 6.0.0 +* 3681 `ScriptAssemblyResolver` logging should be at debug/diagnostic level +* 3662 Update Microsoft.CodeAnalysis.CSharp.Scripting to 4.0.0-6.final +* 3647 Display message of criteria when task fails to run due to criteria not being met +* 3644 Add DotNetNuGetUpdateSource aliases (synonym to DotNetCoreNuGetUpdateSource) +* 3643 Add DotNetNuGetRemoveSource aliases (synonym to DotNetCoreNuGetRemoveSource) +* 3642 Add DotNetNuGetListSourceSettings (derived from to DotNetNuGetSource) +* 3641 Add DotNetNuGetHasSource aliases (synonym to DotNetCoreNuGetHasSource) +* 3640 Add DotNetNuGetEnableSource aliases (synonym to DotNetCoreNuGetEnableSource) +* 3639 Add DotNetNuGetDisableSource aliases (synonym to DotNetCoreNuGetDisableSource) +* 3607 Add `EnableCompressionInSingleFile` to `DotNetCorePublishSettings` +* 3599 Add VS2022 to default MSBuild Resolver +* 3598 Remove Preview from VS2022 MSBuild Resolver +* 3595 Update Autofac to 6.3.0 +* 3593 Update Microsoft.CodeAnalysis.CSharp.Scripting to 4.0.0-5.final +* 3591 Update Microsoft.NETCore.Platforms to 6.0.0-rc.2.21480.5 +* 3555 Add DotNetNuGetAddSource aliases (synonym to DotNetCoreNuGetAddSource) +* 3554 Add DotNetNuGetDelete aliases (synonym to DotNetCoreNuGetDelete) +* 3553 Add DotNetNuGetPush aliases (synonym to DotNetCoreNuGetPush) +* 3552 Add DotNetPack alias (synonym to DotNetCorePack) +* 3551 Add DotNetPublish alias (synonym to DotNetCorePublish) +* 3550 Add DotNetVSTest alias (synonym to DotNetCoreVSTest) +* 3549 Add DotNetTest alias (synonym to DotNetCoreTest) +* 3548 Add DotNetBuildServer alias (synonym to DotNetCoreBuildServer) +* 3547 Add DotNetBuild alias (synonym to DotNetCoreBuild) +* 3546 Add DotNetRestore alias (synonym to DotNetCoreRestore) +* 3545 Add DotNetClean alias (synonym to DotNetCoreClean) +* 3544 Add DotNetExecute alias (synonym to DotNetCoreExecute) +* 3543 Add DotNetRun alias (synonym to DotNetCoreRun) +* 3542 Add DotNetTool alias (synonym to DotNetCoreTool) +* 3523 Add DotNetMSBuild alias (synonym to DotNetCoreMSBuild) +* 3215 Add RunCommand with postAction parameter to DotNetCoreTool +* 3075 Make FilePath and DirectoryPath comparable by value +* 2571 OctopusDeploy DeployTo property to take collection of string to specify multiple environments +* 2075 Add overloads for DotNetCore*() methods taking FilePath instead of string +* 1794 Private is missing from ProjectReference +* 1616 Error message on circular references leads to poor developer experience +* 3701 Add cake-module tag to Cake.DotNetTool.Module NuGet package +* 3602 Switch to Cake.Tool as primary package in REAME.md + +### New in 2.0.0-rc0001 (Released 2021/11/07) + +* 3654 IsRunningOnAzurePipelines should ignore agent type +* 3631 Refactor GitHub Actions Paths +* 3610 Remove TFBuildProvider +* 3590 Directories in AzurePipelinesBuildInfo are FilePaths - FilePath.GetDirectory then inconsistent +* 3581 Stop shipping Cake.Portable Chocolatey package and Cake Homebrew formulae +* 3579 Stop shipping Cake runner for .NET Framework and Cake runner for .NET Core +* 3577 Remove ReverseDependencyAttribute +* 3572 Only build for TargetFrameworks netcoreapp3.1, net5.0 and net6.0 +* 3282 GitVersion Tool: Rename verbosity values to match GitVersion values +* 3222 Add Xamarin.iOS platform targets to MSBuildSettings PlatformTarget enumeration +* 3151 Add support for Engine event hooks after execution as well as before +* 3003 Remove DependencyAttribute +* 2872 Bump eol target frameworks +* 2788 Tool:OpenCover - the register-setting should be an option, rather than a string +* 1111 DotNetCoreRestore: dotnet restore no longer supports globbing +* 3341 Introduce DotNet aliases (synonyms to DotNetCore aliases +* 3627 Add GitHub Actions AddPath Command +* 3628 Add GitHub Actions SetEnvironmentVariable Command +* 3629 Add GitHub Actions UploadArtifact Command +* 3630 Add GitHub Actions Environment properties +* 3662 Update Microsoft.CodeAnalysis.CSharp.Scripting to 4.0.0-6.final +* 3647 Display message of criteria when task fails to run due to criteria not being met +* 3644 Add DotNetNuGetUpdateSource aliases (synonym to DotNetCoreNuGetUpdateSource) +* 3643 Add DotNetNuGetRemoveSource aliases (synonym to DotNetCoreNuGetRemoveSource) +* 3642 Add DotNetNuGetListSourceSettings (derived from to DotNetNuGetSource) +* 3641 Add DotNetNuGetHasSource aliases (synonym to DotNetCoreNuGetHasSource) +* 3640 Add DotNetNuGetEnableSource aliases (synonym to DotNetCoreNuGetEnableSource) +* 3639 Add DotNetNuGetDisableSource aliases (synonym to DotNetCoreNuGetDisableSource) +* 3607 Add EnableCompressionInSingleFile to DotNetCorePublishSettings +* 3599 Add VS2022 to default MSBuild Resolver +* 3598 Remove Preview from VS2022 MSBuild Resolver +* 3595 Update Autofac to 6.3.0 +* 3593 Update Microsoft.CodeAnalysis.CSharp.Scripting to 4.0.0-5.final +* 3591 Update Microsoft.NETCore.Platforms to 6.0.0-rc.2.21480.5 +* 3555 Add DotNetNuGetAddSource aliases (synonym to DotNetCoreNuGetAddSource) +* 3554 Add DotNetNuGetDelete aliases (synonym to DotNetCoreNuGetDelete) +* 3553 Add DotNetNuGetPush aliases (synonym to DotNetCoreNuGetPush) +* 3552 Add DotNetPack alias (synonym to DotNetCorePack) +* 3551 Add DotNetPublish alias (synonym to DotNetCorePublish) +* 3550 Add DotNetVSTest alias (synonym to DotNetCoreVSTest) +* 3549 Add DotNetTest alias (synonym to DotNetCoreTest) +* 3548 Add DotNetBuildServer alias (synonym to DotNetCoreBuildServer) +* 3547 Add DotNetBuild alias (synonym to DotNetCoreBuild) +* 3546 Add DotNetRestore alias (synonym to DotNetCoreRestore) +* 3545 Add DotNetClean alias (synonym to DotNetCoreClean) +* 3544 Add DotNetExecute alias (synonym to DotNetCoreExecute) +* 3543 Add DotNetRun alias (synonym to DotNetCoreRun) +* 3542 Add DotNetTool alias (synonym to DotNetCoreTool) +* 3523 Add DotNetMSBuild alias (synonym to DotNetCoreMSBuild) +* 3215 Add RunCommand with postAction parameter to DotNetCoreTool +* 3075 Make FilePath and DirectoryPath comparable by value +* 2571 OctopusDeploy DeployTo property to take collection of string to specify multiple environments +* 2075 Add overloads for DotNetCore*() methods taking FilePath instead of string +* 1794 Private is missing from ProjectReference +* 1616 Error message on circular references leads to poor developer experience +* 1669 Release notes does not tolerate prerelease versions +* 2443 Erroneous "Target path must be an absolute path" when preserveFolderStructure is used with CopyFiles +* 3602 Switch to Cake.Tool as primary package in REAME.md + ### New in 1.3.0 (Released 2021/10/07) * 3469 Add support for .NET 6 diff --git a/build.cake b/build.cake index fba0e0d50d..6aa278ea66 100644 --- a/build.cake +++ b/build.cake @@ -415,6 +415,8 @@ Task("Run-Integration-Tests") .AppendSwitchQuoted("--multipleargs", "=", "b") .AppendSwitchQuoted("--testAssemblyDirectoryPath", "=", cakeAssembly.GetDirectory().FullPath) .AppendSwitchQuoted("--testAssemblyFilePath", "=", cakeAssembly.FullPath) + .AppendSwitchQuoted("--testDotNetCoreVerbosity", "=", "Diagnostic") + .AppendSwitchQuoted("--testDotNetRollForward", "=", "LatestMajor") }); } catch(Exception ex) diff --git a/global.json b/global.json index 08853e58b7..5c4c1f8aeb 100644 --- a/global.json +++ b/global.json @@ -3,7 +3,7 @@ "src" ], "sdk": { - "version": "6.0.100-rc.2.21505.57", + "version": "6.0.100", "rollForward": "latestFeature" } } \ No newline at end of file diff --git a/src/Cake.Common.Tests/Fixtures/Tools/DotNetCore/Build/DotNetCoreBuilderFixture.cs b/src/Cake.Common.Tests/Fixtures/Tools/DotNetCore/Build/DotNetCoreBuilderFixture.cs index 5371e0dac6..44b431f3c6 100644 --- a/src/Cake.Common.Tests/Fixtures/Tools/DotNetCore/Build/DotNetCoreBuilderFixture.cs +++ b/src/Cake.Common.Tests/Fixtures/Tools/DotNetCore/Build/DotNetCoreBuilderFixture.cs @@ -2,11 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Cake.Common.Tools.DotNet.Build; using Cake.Common.Tools.DotNetCore.Build; namespace Cake.Common.Tests.Fixtures.Tools.DotNetCore.Build { - internal sealed class DotNetCoreBuilderFixture : DotNetCoreFixture + internal sealed class DotNetCoreBuilderFixture : DotNetCoreFixture { public string Project { get; set; } diff --git a/src/Cake.Common.Tests/Fixtures/Tools/DotNetCore/BuildServer/DotNetCoreBuildServerFixture.cs b/src/Cake.Common.Tests/Fixtures/Tools/DotNetCore/BuildServer/DotNetCoreBuildServerFixture.cs index ad95e31829..c32030ee07 100644 --- a/src/Cake.Common.Tests/Fixtures/Tools/DotNetCore/BuildServer/DotNetCoreBuildServerFixture.cs +++ b/src/Cake.Common.Tests/Fixtures/Tools/DotNetCore/BuildServer/DotNetCoreBuildServerFixture.cs @@ -2,11 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Cake.Common.Tools.DotNet.BuildServer; using Cake.Common.Tools.DotNetCore.BuildServer; namespace Cake.Common.Tests.Fixtures.Tools.DotNetCore.Build { - internal sealed class DotNetCoreBuildServerFixture : DotNetCoreFixture + internal sealed class DotNetCoreBuildServerFixture : DotNetCoreFixture { protected override void RunTool() { diff --git a/src/Cake.Common.Tests/Fixtures/Tools/DotNetCore/Clean/DotNetCoreCleanerFixture.cs b/src/Cake.Common.Tests/Fixtures/Tools/DotNetCore/Clean/DotNetCoreCleanerFixture.cs index e8b1621727..3b6e3a25d7 100644 --- a/src/Cake.Common.Tests/Fixtures/Tools/DotNetCore/Clean/DotNetCoreCleanerFixture.cs +++ b/src/Cake.Common.Tests/Fixtures/Tools/DotNetCore/Clean/DotNetCoreCleanerFixture.cs @@ -2,11 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Cake.Common.Tools.DotNet.Clean; using Cake.Common.Tools.DotNetCore.Clean; namespace Cake.Common.Tests.Fixtures.Tools.DotNetCore.Clean { - internal sealed class DotNetCoreCleanerFixture : DotNetCoreFixture + internal sealed class DotNetCoreCleanerFixture : DotNetCoreFixture { public string Project { get; set; } diff --git a/src/Cake.Common.Tests/Fixtures/Tools/DotNetCore/DotNetCoreFixture.cs b/src/Cake.Common.Tests/Fixtures/Tools/DotNetCore/DotNetCoreFixture.cs index 4bb1c669d2..6f95302d4b 100644 --- a/src/Cake.Common.Tests/Fixtures/Tools/DotNetCore/DotNetCoreFixture.cs +++ b/src/Cake.Common.Tests/Fixtures/Tools/DotNetCore/DotNetCoreFixture.cs @@ -2,14 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Cake.Common.Tools.DotNetCore; +using Cake.Common.Tools.DotNet; using Cake.Core.IO; using Cake.Testing.Fixtures; namespace Cake.Common.Tests.Fixtures.Tools.DotNetCore { internal abstract class DotNetCoreFixture : ToolFixture - where TSettings : DotNetCoreSettings, new() + where TSettings : DotNetSettings, new() { protected DotNetCoreFixture() : base("dotnet.exe") diff --git a/src/Cake.Common.Tests/Unit/ArgumentAliasesTests.cs b/src/Cake.Common.Tests/Unit/ArgumentAliasesTests.cs index 8681aebf5b..0d58f75a09 100644 --- a/src/Cake.Common.Tests/Unit/ArgumentAliasesTests.cs +++ b/src/Cake.Common.Tests/Unit/ArgumentAliasesTests.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; using System.Collections.Generic; using System.Linq; using Cake.Core; @@ -73,6 +74,57 @@ public void Should_Return_An_Arguments_Dictionary() Assert.Equal(VerboseArgumentValueOne, vValues.ElementAt(0)); Assert.Equal(VerboseArgumentValueTwo, vValues.ElementAt(1)); } + + [Fact] + public void Should_Return_An_Arguments_With_Single_DefaultValue() + { + var context = Substitute.For(); + context.Arguments.GetArguments(Arg.Any()) + .Returns(Array.Empty()); + + // Given + var expect = new[] { "a" }; + + // When + var arg = context.Arguments("nonexistingmultipleargs", expect[0]); + + // Then + Assert.Equal(expect, arg); + } + + [Fact] + public void Should_Return_An_Arguments_With_Multiple_DefaultValue() + { + var context = Substitute.For(); + context.Arguments.GetArguments(Arg.Any()) + .Returns(Array.Empty()); + + // Given + var expect = new[] { "a", "b" }; + + // When + var arg = context.Arguments("nonexistingmultipleargs", expect); + + // Then + Assert.Equal(expect, arg); + } + + [Fact] + public void Should_Return_An_Arguments_With_Lazy_DefaultValue() + { + var context = Substitute.For(); + context.Arguments.GetArguments(Arg.Any()) + .Returns(Array.Empty()); + + // Given + var expect = new[] { "a", "b" }; + + // When + var arg = context.Arguments("nonexistingmultipleargs", _ => expect); + + // Then + Assert.Equal(expect, arg); + } } } } diff --git a/src/Cake.Common.Tests/Unit/SemVerTests.cs b/src/Cake.Common.Tests/Unit/SemVerTests.cs new file mode 100644 index 0000000000..f1e1a5bb17 --- /dev/null +++ b/src/Cake.Common.Tests/Unit/SemVerTests.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; + +namespace Cake.Common.Tests.Unit +{ + public sealed class SemVerTests + { + public sealed class TheTryParseMethod + { + [Fact] + public void Should_Return_False_If_Version_Is_Null() + { + // Given + string version = null; + + // When + var result = SemVersion.TryParse(version, out _); + + // Then + Assert.False(result); + } + + [Theory] + [InlineData(1, 2, 3, null, null, "1.2.3")] + [InlineData(1, 2, 3, "rc001", null, "1.2.3-rc001")] + [InlineData(1, 2, 3, "rc001", "meta1", "1.2.3-rc001+meta1")] + public void Should_Return_True_If_Version_Is_Valid(int major, int minor, int patch, string preRelease, string meta, string versionString) + { + // Given + var expect = new SemVersion(major, minor, patch, preRelease, meta); + + // When + var result = SemVersion.TryParse(versionString, out var parsedSemVersion); + + // Then + Assert.True(result, nameof(SemVersion.TryParse)); + Assert.Equal(expect, parsedSemVersion); + Assert.True(expect == parsedSemVersion, "expect == parsedSemVersion"); + Assert.Equal(versionString, parsedSemVersion.VersionString); + } + } + + public sealed class Operators + { + private const bool ExpectGreaterThanTrue = true; + private const bool ExpectGreaterThanFalse = false; + private const bool ExpectLessThanTrue = true; + private const bool ExpectLessThanFalse = false; + private const bool ExpectGreaterThanOrEqualTrue = true; + private const bool ExpectGreaterThanOrEqualFalse = false; + private const bool ExpectLesserThanOrEqualTrue = true; + private const bool ExpectLesserThanOrEqualFalse = false; + private const bool ExpectEqualToTrue = true; + private const bool ExpectEqualToFalse = false; + private const bool ExpectNotEqualToTrue = true; + private const bool ExpectNotEqualToFalse = false; + + [Theory] + [InlineData("1.2.3", "1.2.3", ExpectGreaterThanFalse, ExpectLessThanFalse, ExpectGreaterThanOrEqualTrue, ExpectLesserThanOrEqualTrue, ExpectEqualToTrue, ExpectNotEqualToFalse)] + [InlineData("1.2.4", "1.2.3", ExpectGreaterThanTrue, ExpectLessThanFalse, ExpectGreaterThanOrEqualTrue, ExpectLesserThanOrEqualFalse, ExpectEqualToFalse, ExpectNotEqualToTrue)] + [InlineData("1.2.3", "1.2.4", ExpectGreaterThanFalse, ExpectLessThanTrue, ExpectGreaterThanOrEqualFalse, ExpectLesserThanOrEqualTrue, ExpectEqualToFalse, ExpectNotEqualToTrue)] + [InlineData("1.2.3-rc001", "1.2.3-rc001", ExpectGreaterThanFalse, ExpectLessThanFalse, ExpectGreaterThanOrEqualTrue, ExpectLesserThanOrEqualTrue, ExpectEqualToTrue, ExpectNotEqualToFalse)] + [InlineData("1.2.4-rc001", "1.2.3-rc001", ExpectGreaterThanTrue, ExpectLessThanFalse, ExpectGreaterThanOrEqualTrue, ExpectLesserThanOrEqualFalse, ExpectEqualToFalse, ExpectNotEqualToTrue)] + [InlineData("1.2.3-rc001", "1.2.4-rc001", ExpectGreaterThanFalse, ExpectLessThanTrue, ExpectGreaterThanOrEqualFalse, ExpectLesserThanOrEqualTrue, ExpectEqualToFalse, ExpectNotEqualToTrue)] + [InlineData("1.2.3-rc001+meta001", "1.2.3-rc001+meta001", ExpectGreaterThanFalse, ExpectLessThanFalse, ExpectGreaterThanOrEqualTrue, ExpectLesserThanOrEqualTrue, ExpectEqualToTrue, ExpectNotEqualToFalse)] + [InlineData("1.2.4-rc001+meta001", "1.2.3-rc001+meta001", ExpectGreaterThanTrue, ExpectLessThanFalse, ExpectGreaterThanOrEqualTrue, ExpectLesserThanOrEqualFalse, ExpectEqualToFalse, ExpectNotEqualToTrue)] + [InlineData("1.2.3-rc001+meta001", "1.2.4-rc001+meta001", ExpectGreaterThanFalse, ExpectLessThanTrue, ExpectGreaterThanOrEqualFalse, ExpectLesserThanOrEqualTrue, ExpectEqualToFalse, ExpectNotEqualToTrue)] + [InlineData("1.2.3", "1.2.3-rc001", ExpectGreaterThanTrue, ExpectLessThanFalse, ExpectGreaterThanOrEqualTrue, ExpectLesserThanOrEqualFalse, ExpectEqualToFalse, ExpectNotEqualToTrue)] + [InlineData("1.2.3-rc001", "1.2.3", ExpectGreaterThanFalse, ExpectLessThanTrue, ExpectGreaterThanOrEqualFalse, ExpectLesserThanOrEqualTrue, ExpectEqualToFalse, ExpectNotEqualToTrue)] + [InlineData("1.2.3-rc001", "1.2.3-rc001+meta001", ExpectGreaterThanTrue, ExpectLessThanFalse, ExpectGreaterThanOrEqualTrue, ExpectLesserThanOrEqualFalse, ExpectEqualToFalse, ExpectNotEqualToTrue)] + [InlineData("1.2.3-rc001+meta001", "1.2.3-rc001", ExpectGreaterThanFalse, ExpectLessThanTrue, ExpectGreaterThanOrEqualFalse, ExpectLesserThanOrEqualTrue, ExpectEqualToFalse, ExpectNotEqualToTrue)] + public void Should_Return_Expected(string operand1string, string operand2string, bool expectGreaterThan, bool expectLessThan, bool expectGreaterThanOrEqual, bool expectLesserThanOrEqual, bool expectEqualTo, bool expectNotEqualTo) + { + // Given + var expect = new + { + ParsedOperand1 = true, + ParsedOperand2 = true, + GreaterThan = expectGreaterThan, + LessThan = expectLessThan, + GreaterThanOrEqual = expectGreaterThanOrEqual, + LesserThanOrEqual = expectLesserThanOrEqual, + EqualTo = expectEqualTo, + NotEqualTo = expectNotEqualTo + }; + + // When + var result = new + { + ParsedOperand1 = SemVersion.TryParse(operand1string, out var operand1), + ParsedOperand2 = SemVersion.TryParse(operand2string, out var operand2), + GreaterThan = operand1 > operand2, + LessThan = operand1 < operand2, + GreaterThanOrEqual = operand1 >= operand2, + LesserThanOrEqual = operand1 <= operand2, + EqualTo = operand1 == operand2, + NotEqualTo = operand1 != operand2, + }; + + // Then + Assert.Equal(expect, result); + } + } + } +} diff --git a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Build/DotNetCoreBuilderTests.cs b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Build/DotNetCoreBuilderTests.cs index 0b37fbff90..d9abf8fe8f 100644 --- a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Build/DotNetCoreBuilderTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Build/DotNetCoreBuilderTests.cs @@ -57,7 +57,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -72,7 +72,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] diff --git a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/BuildServer/DotNetCoreBuildServerTests.cs b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/BuildServer/DotNetCoreBuildServerTests.cs index 63138e35a3..6bc2ade4da 100644 --- a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/BuildServer/DotNetCoreBuildServerTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/BuildServer/DotNetCoreBuildServerTests.cs @@ -40,7 +40,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -54,7 +54,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] diff --git a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Clean/DotNetCoreCleanTests.cs b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Clean/DotNetCoreCleanTests.cs index f03be343b3..b8f3da7fa1 100644 --- a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Clean/DotNetCoreCleanTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Clean/DotNetCoreCleanTests.cs @@ -58,7 +58,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -73,7 +73,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] diff --git a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Execute/DotNetCoreExecutorTests.cs b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Execute/DotNetCoreExecutorTests.cs index aec2d1395d..c557748f71 100644 --- a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Execute/DotNetCoreExecutorTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Execute/DotNetCoreExecutorTests.cs @@ -44,7 +44,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -61,7 +61,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] diff --git a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/MSBuild/DotNetCoreMSBuildBuilderTests.cs b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/MSBuild/DotNetCoreMSBuildBuilderTests.cs index 5028153685..870a0dfd0a 100644 --- a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/MSBuild/DotNetCoreMSBuildBuilderTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/MSBuild/DotNetCoreMSBuildBuilderTests.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using Cake.Common.Tests.Fixtures.Tools.DotNetCore.MSBuild; +using Cake.Common.Tools.DotNet; using Cake.Common.Tools.DotNetCore; using Cake.Common.Tools.DotNetCore.MSBuild; using Cake.Common.Tools.MSBuild; @@ -64,7 +65,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -81,7 +82,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] @@ -1013,12 +1014,12 @@ public void Should_Append_DisableMultiprocessorLogging_If_Specified() } [Theory] - [InlineData(DotNetCoreVerbosity.Quiet)] - [InlineData(DotNetCoreVerbosity.Minimal)] - [InlineData(DotNetCoreVerbosity.Normal)] - [InlineData(DotNetCoreVerbosity.Detailed)] - [InlineData(DotNetCoreVerbosity.Diagnostic)] - public void Should_Append_Verbosity_If_Specified(DotNetCoreVerbosity verbosity) + [InlineData(DotNetVerbosity.Quiet)] + [InlineData(DotNetVerbosity.Minimal)] + [InlineData(DotNetVerbosity.Normal)] + [InlineData(DotNetVerbosity.Detailed)] + [InlineData(DotNetVerbosity.Diagnostic)] + public void Should_Append_Verbosity_If_Specified(DotNetVerbosity verbosity) { // Given var fixture = new DotNetCoreMSBuildBuilderFixture(); @@ -1270,12 +1271,12 @@ public void Should_Append_DisableMultiprocessorLogging_If_Specified() } [Theory] - [InlineData(DotNetCoreVerbosity.Quiet)] - [InlineData(DotNetCoreVerbosity.Minimal)] - [InlineData(DotNetCoreVerbosity.Normal)] - [InlineData(DotNetCoreVerbosity.Detailed)] - [InlineData(DotNetCoreVerbosity.Diagnostic)] - public void Should_Append_Verbosity_If_Specified(DotNetCoreVerbosity verbosity) + [InlineData(DotNetVerbosity.Quiet)] + [InlineData(DotNetVerbosity.Minimal)] + [InlineData(DotNetVerbosity.Normal)] + [InlineData(DotNetVerbosity.Detailed)] + [InlineData(DotNetVerbosity.Diagnostic)] + public void Should_Append_Verbosity_If_Specified(DotNetVerbosity verbosity) { // Given var fixture = new DotNetCoreMSBuildBuilderFixture(); diff --git a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/NuGet/Delete/DotNetCoreNuGetDeleterTests.cs b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/NuGet/Delete/DotNetCoreNuGetDeleterTests.cs index 62623d734f..b013f82e74 100644 --- a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/NuGet/Delete/DotNetCoreNuGetDeleterTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/NuGet/Delete/DotNetCoreNuGetDeleterTests.cs @@ -76,7 +76,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -90,7 +90,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] diff --git a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/NuGet/Push/DotNetCoreNuGetPusherTests.cs b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/NuGet/Push/DotNetCoreNuGetPusherTests.cs index 5ba3239f0a..2686e4b72f 100644 --- a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/NuGet/Push/DotNetCoreNuGetPusherTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/NuGet/Push/DotNetCoreNuGetPusherTests.cs @@ -58,7 +58,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -73,7 +73,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] diff --git a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/NuGet/Source/DotNetCoreNuGetSourcerTests.cs b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/NuGet/Source/DotNetCoreNuGetSourcerTests.cs index f799b52274..aee207d3f5 100644 --- a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/NuGet/Source/DotNetCoreNuGetSourcerTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/NuGet/Source/DotNetCoreNuGetSourcerTests.cs @@ -73,7 +73,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -88,7 +88,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] @@ -185,7 +185,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -199,7 +199,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] @@ -274,7 +274,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -288,7 +288,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] @@ -363,7 +363,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -377,7 +377,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] @@ -459,7 +459,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -473,7 +473,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] @@ -562,7 +562,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -576,7 +576,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] @@ -651,7 +651,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -665,7 +665,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] diff --git a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Pack/DotNetCorePackerTests.cs b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Pack/DotNetCorePackerTests.cs index 4f50198233..878886bbda 100644 --- a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Pack/DotNetCorePackerTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Pack/DotNetCorePackerTests.cs @@ -39,7 +39,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -53,7 +53,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] diff --git a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Publish/DotNetCorePublisherTests.cs b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Publish/DotNetCorePublisherTests.cs index 9fd34a5826..0752b251f1 100644 --- a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Publish/DotNetCorePublisherTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Publish/DotNetCorePublisherTests.cs @@ -39,7 +39,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -53,7 +53,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] diff --git a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Restore/DotNetCoreRestorerTests.cs b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Restore/DotNetCoreRestorerTests.cs index db3c8def41..fd6107a33e 100644 --- a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Restore/DotNetCoreRestorerTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Restore/DotNetCoreRestorerTests.cs @@ -41,7 +41,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -55,7 +55,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] diff --git a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Run/DotNetCoreRunnerTests.cs b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Run/DotNetCoreRunnerTests.cs index 7305805fa8..847c477ad7 100644 --- a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Run/DotNetCoreRunnerTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Run/DotNetCoreRunnerTests.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using Cake.Common.Tests.Fixtures.Tools.DotNetCore.Run; +using Cake.Common.Tools.DotNet; using Cake.Common.Tools.DotNetCore; using Cake.Testing; using Xunit; @@ -41,7 +42,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -56,7 +57,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] @@ -119,13 +120,13 @@ public void Should_Add_Host_Arguments() } [Theory] - [InlineData(DotNetCoreRollForward.Minor, "run --roll-forward Minor")] - [InlineData(DotNetCoreRollForward.LatestPatch, "run --roll-forward LatestPatch")] - [InlineData(DotNetCoreRollForward.Major, "run --roll-forward Major")] - [InlineData(DotNetCoreRollForward.LatestMinor, "run --roll-forward LatestMinor")] - [InlineData(DotNetCoreRollForward.LatestMajor, "run --roll-forward LatestMajor")] - [InlineData(DotNetCoreRollForward.Disable, "run --roll-forward Disable")] - public void Should_Add_RollForward_Arguments(DotNetCoreRollForward rollForward, string expected) + [InlineData(DotNetRollForward.Minor, "run --roll-forward Minor")] + [InlineData(DotNetRollForward.LatestPatch, "run --roll-forward LatestPatch")] + [InlineData(DotNetRollForward.Major, "run --roll-forward Major")] + [InlineData(DotNetRollForward.LatestMinor, "run --roll-forward LatestMinor")] + [InlineData(DotNetRollForward.LatestMajor, "run --roll-forward LatestMajor")] + [InlineData(DotNetRollForward.Disable, "run --roll-forward Disable")] + public void Should_Add_RollForward_Arguments(DotNetRollForward rollForward, string expected) { // Given var fixture = new DotNetCoreRunnerFixture(); diff --git a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Test/DotNetCoreTesterTests.cs b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Test/DotNetCoreTesterTests.cs index 072e8169cc..eaed023794 100644 --- a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Test/DotNetCoreTesterTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Test/DotNetCoreTesterTests.cs @@ -41,7 +41,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -56,7 +56,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] diff --git a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Tool/DotNetCoreToolTests.cs b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Tool/DotNetCoreToolTests.cs index 2e2e1ffb49..d4126dcdc1 100644 --- a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Tool/DotNetCoreToolTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/Tool/DotNetCoreToolTests.cs @@ -77,7 +77,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -94,7 +94,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } } } diff --git a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/VSTest/DotNetCoreVSTesterTests.cs b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/VSTest/DotNetCoreVSTesterTests.cs index 190ba1e455..0d3295f796 100644 --- a/src/Cake.Common.Tests/Unit/Tools/DotNetCore/VSTest/DotNetCoreVSTesterTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/DotNetCore/VSTest/DotNetCoreVSTesterTests.cs @@ -44,7 +44,7 @@ public void Should_Throw_If_Process_Was_Not_Started() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process was not started."); + AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); } [Fact] @@ -58,7 +58,7 @@ public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() var result = Record.Exception(() => fixture.Run()); // Then - AssertEx.IsCakeException(result, ".NET Core CLI: Process returned an error (exit code 1)."); + AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); } [Fact] diff --git a/src/Cake.Common/ArgumentAliases.cs b/src/Cake.Common/ArgumentAliases.cs index 9389c09376..42eb8bca4d 100644 --- a/src/Cake.Common/ArgumentAliases.cs +++ b/src/Cake.Common/ArgumentAliases.cs @@ -155,6 +155,72 @@ public static ICollection Arguments(this ICakeContext context, string name return values.Select(value => Convert(value)).ToArray(); } + /// + /// Gets all arguments with the specific name and returns the + /// provided if the argument is missing. + /// + /// The argument type. + /// The context. + /// The argument name. + /// The values to return if the argument is missing. + /// The argument values. + /// + /// + /// // Cake.exe .\argument.cake --foo="foo" --foo="bar" + /// var arguments = Arguments<string>("foo", new [] { "default" }); + /// Information("Arguments: {0}", string.Join(", ", arguments)); + /// + /// + [CakeMethodAlias] + public static ICollection Arguments(this ICakeContext context, string name, ICollection defaultValues) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + var values = context.Arguments.GetArguments(name); + if (values == null || values.Count == 0) + { + return defaultValues; + } + + return values.Select(value => Convert(value)).ToArray(); + } + + /// + /// Gets all arguments with the specific name, evaluates and returns the + /// provided if the argument is missing. + /// + /// The argument type. + /// The context. + /// The argument name. + /// The values to return if the argument is missing. + /// The argument values. + /// + /// + /// // Cake.exe .\argument.cake --foo="foo" --foo="bar" + /// var arguments = Arguments<string>("foo", ctx => new [] { "default" }); + /// Information("Arguments: {0}", string.Join(", ", arguments)); + /// + /// + [CakeMethodAlias] + public static ICollection Arguments(this ICakeContext context, string name, Func> defaultValues) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + var values = context.Arguments.GetArguments(name); + if (values == null || values.Count == 0) + { + return defaultValues?.Invoke(context); + } + + return values.Select(value => Convert(value)).ToArray(); + } + /// /// Gets an argument and returns the provided if the argument is missing. /// diff --git a/src/Cake.Common/SemanticVersion.cs b/src/Cake.Common/SemanticVersion.cs index f97f5ef82a..eab59cfe7a 100644 --- a/src/Cake.Common/SemanticVersion.cs +++ b/src/Cake.Common/SemanticVersion.cs @@ -201,6 +201,11 @@ public bool Equals(SemVersion other) /// Return 0 if the objects are identical, 1 if the version is newer and -1 if the version is older. public int CompareTo(SemVersion other) { + if (other is null) + { + return 1; + } + if (Equals(other)) { return 0; @@ -236,6 +241,11 @@ public int CompareTo(SemVersion other) return -1; } + if (IsPreRelease != other.IsPreRelease) + { + return other.IsPreRelease ? 1 : -1; + } + switch (StringComparer.InvariantCultureIgnoreCase.Compare(PreRelease, other.PreRelease)) { case 1: @@ -245,7 +255,11 @@ public int CompareTo(SemVersion other) return -1; default: - return StringComparer.InvariantCultureIgnoreCase.Compare(Meta, other.Meta); + { + return (string.IsNullOrEmpty(Meta) != string.IsNullOrEmpty(other.Meta)) + ? string.IsNullOrEmpty(Meta) ? 1 : -1 + : StringComparer.InvariantCultureIgnoreCase.Compare(Meta, other.Meta); + } } } @@ -335,5 +349,23 @@ public override string ToString() /// A value indicating if the operand1 was lesser than or equal to operand2. public static bool operator <=(SemVersion operand1, SemVersion operand2) => operand1.CompareTo(operand2) <= 0; + + /// + /// The equal to-operator for the SemVersion class. + /// + /// first SemVersion. + /// second. SemVersion. + /// A value indicating if the operand1 was equal to operand2. + public static bool operator ==(SemVersion operand1, SemVersion operand2) + => operand1.Equals(operand2); + + /// + /// The not equal to-operator for the SemVersion class. + /// + /// first SemVersion. + /// second. SemVersion. + /// A value indicating if the operand1 was not equal to operand2. + public static bool operator !=(SemVersion operand1, SemVersion operand2) + => !operand1.Equals(operand2); } } diff --git a/src/Cake.Common/Tools/DotNet/Build/DotNetBuildSettings.cs b/src/Cake.Common/Tools/DotNet/Build/DotNetBuildSettings.cs index d6410f5285..756dcfbbc5 100644 --- a/src/Cake.Common/Tools/DotNet/Build/DotNetBuildSettings.cs +++ b/src/Cake.Common/Tools/DotNet/Build/DotNetBuildSettings.cs @@ -3,9 +3,8 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using Cake.Common.Tools.DotNetCore; +using Cake.Common.Tools.DotNet.MSBuild; using Cake.Common.Tools.DotNetCore.Build; -using Cake.Common.Tools.DotNetCore.MSBuild; using Cake.Core.IO; namespace Cake.Common.Tools.DotNet.Build @@ -13,7 +12,7 @@ namespace Cake.Common.Tools.DotNet.Build /// /// Contains settings used by . /// - public class DotNetBuildSettings : DotNetCoreSettings + public class DotNetBuildSettings : DotNetSettings { /// /// Gets or sets the output directory. @@ -79,6 +78,6 @@ public class DotNetBuildSettings : DotNetCoreSettings /// /// Gets or sets additional arguments to be passed to MSBuild. /// - public DotNetCoreMSBuildSettings MSBuildSettings { get; set; } + public DotNetMSBuildSettings MSBuildSettings { get; set; } } } diff --git a/src/Cake.Common/Tools/DotNet/BuildServer/DotNetBuildServerSettings.cs b/src/Cake.Common/Tools/DotNet/BuildServer/DotNetBuildServerSettings.cs index 86eba8b9a5..8e70a96f0a 100644 --- a/src/Cake.Common/Tools/DotNet/BuildServer/DotNetBuildServerSettings.cs +++ b/src/Cake.Common/Tools/DotNet/BuildServer/DotNetBuildServerSettings.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Cake.Common.Tools.DotNetCore; using Cake.Common.Tools.DotNetCore.BuildServer; namespace Cake.Common.Tools.DotNet.BuildServer @@ -10,7 +9,7 @@ namespace Cake.Common.Tools.DotNet.BuildServer /// /// Contains settings used by . /// - public abstract class DotNetBuildServerSettings : DotNetCoreSettings + public abstract class DotNetBuildServerSettings : DotNetSettings { } } diff --git a/src/Cake.Common/Tools/DotNet/Clean/DotNetCleanSettings.cs b/src/Cake.Common/Tools/DotNet/Clean/DotNetCleanSettings.cs index cde43659cc..4c07f94bd6 100644 --- a/src/Cake.Common/Tools/DotNet/Clean/DotNetCleanSettings.cs +++ b/src/Cake.Common/Tools/DotNet/Clean/DotNetCleanSettings.cs @@ -2,9 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Cake.Common.Tools.DotNetCore; +using Cake.Common.Tools.DotNet.MSBuild; using Cake.Common.Tools.DotNetCore.Clean; -using Cake.Common.Tools.DotNetCore.MSBuild; using Cake.Core.IO; namespace Cake.Common.Tools.DotNet.Clean @@ -12,7 +11,7 @@ namespace Cake.Common.Tools.DotNet.Clean /// /// Contains settings used by . /// - public class DotNetCleanSettings : DotNetCoreSettings + public class DotNetCleanSettings : DotNetSettings { /// /// Gets or sets the output directory. @@ -45,6 +44,6 @@ public class DotNetCleanSettings : DotNetCoreSettings /// /// Gets or sets additional arguments to be passed to MSBuild. /// - public DotNetCoreMSBuildSettings MSBuildSettings { get; set; } + public DotNetMSBuildSettings MSBuildSettings { get; set; } } } diff --git a/src/Cake.Common/Tools/DotNet/DotNetAliases.cs b/src/Cake.Common/Tools/DotNet/DotNetAliases.cs index bdaced494c..29b91eb793 100644 --- a/src/Cake.Common/Tools/DotNet/DotNetAliases.cs +++ b/src/Cake.Common/Tools/DotNet/DotNetAliases.cs @@ -42,9 +42,9 @@ namespace Cake.Common.Tools.DotNet { /// - /// Contains functionality related to .NET Core CLI. + /// Contains functionality related to .NET CLI. /// - /// In order to use the commands for this alias, the .Net Core CLI tools will need to be installed on the machine where + /// In order to use the commands for this alias, the .NET CLI tools will need to be installed on the machine where /// the Cake script is being executed. See this page for information /// on how to install. /// diff --git a/src/Cake.Common/Tools/DotNet/DotNetRollForward.cs b/src/Cake.Common/Tools/DotNet/DotNetRollForward.cs index 528966b633..66c03dc589 100644 --- a/src/Cake.Common/Tools/DotNet/DotNetRollForward.cs +++ b/src/Cake.Common/Tools/DotNet/DotNetRollForward.cs @@ -2,43 +2,41 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Cake.Common.Tools.DotNetCore; - namespace Cake.Common.Tools.DotNet { /// /// Contains the roll forward policy to be used. /// - public sealed class DotNetRollForward + public enum DotNetRollForward { /// /// Roll forward to the lowest higher minor version, if requested minor version is missing. /// - public const DotNetCoreRollForward Minor = DotNetCoreRollForward.Minor; + Minor, /// /// Roll forward to the highest patch version. This disables minor version roll forward. /// - public const DotNetCoreRollForward LatestPatch = DotNetCoreRollForward.LatestPatch; + LatestPatch, /// /// Roll forward to lowest higher major version, and lowest minor version, if requested major version is missing. /// - public const DotNetCoreRollForward Major = DotNetCoreRollForward.Major; + Major, /// /// Roll forward to highest minor version, even if requested minor version is present. /// - public const DotNetCoreRollForward LatestMinor = DotNetCoreRollForward.LatestMinor; + LatestMinor, /// /// Roll forward to highest major and highest minor version, even if requested major is present. /// - public const DotNetCoreRollForward LatestMajor = DotNetCoreRollForward.LatestMajor; + LatestMajor, /// /// Don't roll forward. Only bind to specified version. /// - public const DotNetCoreRollForward Disable = DotNetCoreRollForward.Disable; + Disable, } } diff --git a/src/Cake.Common/Tools/DotNet/DotNetSettings.cs b/src/Cake.Common/Tools/DotNet/DotNetSettings.cs index e7ffab853b..7ad53356f2 100644 --- a/src/Cake.Common/Tools/DotNet/DotNetSettings.cs +++ b/src/Cake.Common/Tools/DotNet/DotNetSettings.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Cake.Common.Tools.DotNetCore; using Cake.Core.Tooling; namespace Cake.Common.Tools.DotNet @@ -15,7 +14,7 @@ public abstract class DotNetSettings : ToolSettings /// /// Gets or sets the verbosity of logging to use. /// - public DotNetCoreVerbosity? Verbosity { get; set; } + public DotNetVerbosity? Verbosity { get; set; } /// /// Gets or sets a value indicating whether to not enable diagnostic output. @@ -25,6 +24,6 @@ public abstract class DotNetSettings : ToolSettings /// /// Gets or sets the dotnet roll forward policy. /// - public DotNetCoreRollForward? RollForward { get; set; } + public DotNetRollForward? RollForward { get; set; } } } diff --git a/src/Cake.Common/Tools/DotNet/DotNetTool.cs b/src/Cake.Common/Tools/DotNet/DotNetTool.cs index aacdf5b7f9..5d473e01f3 100644 --- a/src/Cake.Common/Tools/DotNet/DotNetTool.cs +++ b/src/Cake.Common/Tools/DotNet/DotNetTool.cs @@ -39,7 +39,7 @@ protected DotNetTool( /// The name of the tool. protected override string GetToolName() { - return ".NET Core CLI"; + return ".NET CLI"; } /// diff --git a/src/Cake.Common/Tools/DotNet/DotNetVerbosity.cs b/src/Cake.Common/Tools/DotNet/DotNetVerbosity.cs index f1c3d1d387..4445ccbf17 100644 --- a/src/Cake.Common/Tools/DotNet/DotNetVerbosity.cs +++ b/src/Cake.Common/Tools/DotNet/DotNetVerbosity.cs @@ -2,38 +2,36 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Cake.Common.Tools.DotNetCore; - namespace Cake.Common.Tools.DotNet { /// /// Contains the verbosity of logging to use. /// - public sealed class DotNetVerbosity + public enum DotNetVerbosity { /// /// Quiet level. /// - public const DotNetCoreVerbosity Quiet = DotNetCoreVerbosity.Quiet; + Quiet, /// /// Minimal level. /// - public const DotNetCoreVerbosity Minimal = DotNetCoreVerbosity.Minimal; + Minimal, /// /// Normal level. /// - public const DotNetCoreVerbosity Normal = DotNetCoreVerbosity.Normal; + Normal, /// /// Detailed level. /// - public const DotNetCoreVerbosity Detailed = DotNetCoreVerbosity.Detailed; + Detailed, /// /// Diagnostic level. /// - public const DotNetCoreVerbosity Diagnostic = DotNetCoreVerbosity.Diagnostic; + Diagnostic, } } diff --git a/src/Cake.Common/Tools/DotNet/Execute/DotNetExecuteSettings.cs b/src/Cake.Common/Tools/DotNet/Execute/DotNetExecuteSettings.cs index 613e43c9cc..5bda04ca2c 100644 --- a/src/Cake.Common/Tools/DotNet/Execute/DotNetExecuteSettings.cs +++ b/src/Cake.Common/Tools/DotNet/Execute/DotNetExecuteSettings.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Cake.Common.Tools.DotNetCore; using Cake.Common.Tools.DotNetCore.Execute; namespace Cake.Common.Tools.DotNet.Execute @@ -10,7 +9,7 @@ namespace Cake.Common.Tools.DotNet.Execute /// /// Contains settings used by . /// - public class DotNetExecuteSettings : DotNetCoreSettings + public class DotNetExecuteSettings : DotNetSettings { /// /// Gets or sets the version of the installed Shared Framework to use to run the application. diff --git a/src/Cake.Common/Tools/DotNet/MSBuild/DotNetMSBuildSettings.cs b/src/Cake.Common/Tools/DotNet/MSBuild/DotNetMSBuildSettings.cs index e5665ffee3..93f31ea2ae 100644 --- a/src/Cake.Common/Tools/DotNet/MSBuild/DotNetMSBuildSettings.cs +++ b/src/Cake.Common/Tools/DotNet/MSBuild/DotNetMSBuildSettings.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; -using Cake.Common.Tools.DotNetCore; using Cake.Common.Tools.DotNetCore.MSBuild; using Cake.Common.Tools.MSBuild; using Cake.Core.IO; @@ -14,7 +13,7 @@ namespace Cake.Common.Tools.DotNet.MSBuild /// /// Contains settings used by . /// - public class DotNetMSBuildSettings : DotNetCoreSettings + public class DotNetMSBuildSettings : DotNetSettings { /// /// Gets or sets a value indicating whether to show detailed information at the end of the build log about the configurations that were built and how they were scheduled to nodes. diff --git a/src/Cake.Common/Tools/DotNet/NuGet/Delete/DotNetNuGetDeleteSettings.cs b/src/Cake.Common/Tools/DotNet/NuGet/Delete/DotNetNuGetDeleteSettings.cs index fb1c5eaf84..6635c04ba3 100644 --- a/src/Cake.Common/Tools/DotNet/NuGet/Delete/DotNetNuGetDeleteSettings.cs +++ b/src/Cake.Common/Tools/DotNet/NuGet/Delete/DotNetNuGetDeleteSettings.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Cake.Common.Tools.DotNetCore; using Cake.Common.Tools.DotNetCore.NuGet.Delete; namespace Cake.Common.Tools.DotNet.NuGet.Delete @@ -10,7 +9,7 @@ namespace Cake.Common.Tools.DotNet.NuGet.Delete /// /// Contains settings used by . /// - public class DotNetNuGetDeleteSettings : DotNetCoreSettings + public class DotNetNuGetDeleteSettings : DotNetSettings { /// /// Gets or sets a value indicating the server URL. diff --git a/src/Cake.Common/Tools/DotNet/NuGet/Push/DotNetNuGetPushSettings.cs b/src/Cake.Common/Tools/DotNet/NuGet/Push/DotNetNuGetPushSettings.cs index 0b0eac68b1..0a0c13a76b 100644 --- a/src/Cake.Common/Tools/DotNet/NuGet/Push/DotNetNuGetPushSettings.cs +++ b/src/Cake.Common/Tools/DotNet/NuGet/Push/DotNetNuGetPushSettings.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Cake.Common.Tools.DotNetCore; using Cake.Common.Tools.DotNetCore.NuGet.Push; namespace Cake.Common.Tools.DotNet.NuGet.Push @@ -10,7 +9,7 @@ namespace Cake.Common.Tools.DotNet.NuGet.Push /// /// Contains settings used by . /// - public class DotNetNuGetPushSettings : DotNetCoreSettings + public class DotNetNuGetPushSettings : DotNetSettings { /// /// Gets or sets a value indicating the server URL. diff --git a/src/Cake.Common/Tools/DotNet/NuGet/Source/DotNetNuGetSourceSettings.cs b/src/Cake.Common/Tools/DotNet/NuGet/Source/DotNetNuGetSourceSettings.cs index b272680964..4b48f7b486 100644 --- a/src/Cake.Common/Tools/DotNet/NuGet/Source/DotNetNuGetSourceSettings.cs +++ b/src/Cake.Common/Tools/DotNet/NuGet/Source/DotNetNuGetSourceSettings.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Cake.Common.Tools.DotNetCore; using Cake.Common.Tools.DotNetCore.NuGet.Source; using Cake.Core.IO; @@ -11,7 +10,7 @@ namespace Cake.Common.Tools.DotNet.NuGet.Source /// /// Contains settings used by . /// - public class DotNetNuGetSourceSettings : DotNetCoreSettings + public class DotNetNuGetSourceSettings : DotNetSettings { /// /// Gets or sets the path to the package(s) source. diff --git a/src/Cake.Common/Tools/DotNet/Pack/DotNetPackSettings.cs b/src/Cake.Common/Tools/DotNet/Pack/DotNetPackSettings.cs index 103ca0aa43..2395fc5058 100644 --- a/src/Cake.Common/Tools/DotNet/Pack/DotNetPackSettings.cs +++ b/src/Cake.Common/Tools/DotNet/Pack/DotNetPackSettings.cs @@ -3,8 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using Cake.Common.Tools.DotNetCore; -using Cake.Common.Tools.DotNetCore.MSBuild; +using Cake.Common.Tools.DotNet.MSBuild; using Cake.Common.Tools.DotNetCore.Pack; using Cake.Core.IO; @@ -13,7 +12,7 @@ namespace Cake.Common.Tools.DotNet.Pack /// /// Contains settings used by . /// - public class DotNetPackSettings : DotNetCoreSettings + public class DotNetPackSettings : DotNetSettings { /// /// Gets or sets the output directory. @@ -101,6 +100,6 @@ public class DotNetPackSettings : DotNetCoreSettings /// /// Gets or sets additional arguments to be passed to MSBuild. /// - public DotNetCoreMSBuildSettings MSBuildSettings { get; set; } + public DotNetMSBuildSettings MSBuildSettings { get; set; } } } diff --git a/src/Cake.Common/Tools/DotNet/Publish/DotNetPublishSettings.cs b/src/Cake.Common/Tools/DotNet/Publish/DotNetPublishSettings.cs index 76621f94a8..69de1172d3 100644 --- a/src/Cake.Common/Tools/DotNet/Publish/DotNetPublishSettings.cs +++ b/src/Cake.Common/Tools/DotNet/Publish/DotNetPublishSettings.cs @@ -3,8 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using Cake.Common.Tools.DotNetCore; -using Cake.Common.Tools.DotNetCore.MSBuild; +using Cake.Common.Tools.DotNet.MSBuild; using Cake.Common.Tools.DotNetCore.Publish; using Cake.Core.IO; @@ -13,7 +12,7 @@ namespace Cake.Common.Tools.DotNet.Publish /// /// Contains settings used by . /// - public class DotNetPublishSettings : DotNetCoreSettings + public class DotNetPublishSettings : DotNetSettings { /// /// Gets or sets the output directory. @@ -175,6 +174,6 @@ public class DotNetPublishSettings : DotNetCoreSettings /// /// Gets or sets additional arguments to be passed to MSBuild. /// - public DotNetCoreMSBuildSettings MSBuildSettings { get; set; } + public DotNetMSBuildSettings MSBuildSettings { get; set; } } } diff --git a/src/Cake.Common/Tools/DotNet/Restore/DotNetRestoreSettings.cs b/src/Cake.Common/Tools/DotNet/Restore/DotNetRestoreSettings.cs index 0f9c3790cd..9e8c3d42ad 100644 --- a/src/Cake.Common/Tools/DotNet/Restore/DotNetRestoreSettings.cs +++ b/src/Cake.Common/Tools/DotNet/Restore/DotNetRestoreSettings.cs @@ -3,8 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using Cake.Common.Tools.DotNetCore; -using Cake.Common.Tools.DotNetCore.MSBuild; +using Cake.Common.Tools.DotNet.MSBuild; using Cake.Common.Tools.DotNetCore.Restore; using Cake.Core.IO; @@ -13,7 +12,7 @@ namespace Cake.Common.Tools.DotNet.Restore /// /// Contains settings used by . /// - public class DotNetRestoreSettings : DotNetCoreSettings + public class DotNetRestoreSettings : DotNetSettings { /// /// Gets or sets the specified NuGet package sources to use during the restore. @@ -113,6 +112,6 @@ public class DotNetRestoreSettings : DotNetCoreSettings /// /// Gets or sets additional arguments to be passed to MSBuild. /// - public DotNetCoreMSBuildSettings MSBuildSettings { get; set; } + public DotNetMSBuildSettings MSBuildSettings { get; set; } } } diff --git a/src/Cake.Common/Tools/DotNet/Run/DotNetRunSettings.cs b/src/Cake.Common/Tools/DotNet/Run/DotNetRunSettings.cs index b8cfe95088..e45b775212 100644 --- a/src/Cake.Common/Tools/DotNet/Run/DotNetRunSettings.cs +++ b/src/Cake.Common/Tools/DotNet/Run/DotNetRunSettings.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using Cake.Common.Tools.DotNetCore; using Cake.Common.Tools.DotNetCore.Run; namespace Cake.Common.Tools.DotNet.Run @@ -11,7 +10,7 @@ namespace Cake.Common.Tools.DotNet.Run /// /// Contains settings used by . /// - public class DotNetRunSettings : DotNetCoreSettings + public class DotNetRunSettings : DotNetSettings { /// /// Gets or sets a specific framework to compile. diff --git a/src/Cake.Common/Tools/DotNet/Test/DotNetTestSettings.cs b/src/Cake.Common/Tools/DotNet/Test/DotNetTestSettings.cs index d89ebd9b4f..8f35942673 100644 --- a/src/Cake.Common/Tools/DotNet/Test/DotNetTestSettings.cs +++ b/src/Cake.Common/Tools/DotNet/Test/DotNetTestSettings.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; -using Cake.Common.Tools.DotNetCore; using Cake.Common.Tools.DotNetCore.Test; using Cake.Core.IO; @@ -13,7 +12,7 @@ namespace Cake.Common.Tools.DotNet.Test /// /// Contains settings used by . /// - public class DotNetTestSettings : DotNetCoreSettings + public class DotNetTestSettings : DotNetSettings { /// /// Gets or sets the settings file to use when running tests. diff --git a/src/Cake.Common/Tools/DotNet/Tool/DotNetToolSettings.cs b/src/Cake.Common/Tools/DotNet/Tool/DotNetToolSettings.cs index d3aa9ad9f7..202b50ca5d 100644 --- a/src/Cake.Common/Tools/DotNet/Tool/DotNetToolSettings.cs +++ b/src/Cake.Common/Tools/DotNet/Tool/DotNetToolSettings.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Cake.Common.Tools.DotNetCore; using Cake.Common.Tools.DotNetCore.Tool; namespace Cake.Common.Tools.DotNet.Tool @@ -10,7 +9,7 @@ namespace Cake.Common.Tools.DotNet.Tool /// /// Contains settings used by . /// - public class DotNetToolSettings : DotNetCoreSettings + public class DotNetToolSettings : DotNetSettings { } } diff --git a/src/Cake.Common/Tools/DotNet/VSTest/DotNetVSTestSettings.cs b/src/Cake.Common/Tools/DotNet/VSTest/DotNetVSTestSettings.cs index 38e4e63395..db69d98cc6 100644 --- a/src/Cake.Common/Tools/DotNet/VSTest/DotNetVSTestSettings.cs +++ b/src/Cake.Common/Tools/DotNet/VSTest/DotNetVSTestSettings.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using Cake.Common.Tools.DotNetCore; using Cake.Common.Tools.DotNetCore.VSTest; using Cake.Common.Tools.VSTest; using Cake.Core.IO; @@ -13,7 +12,7 @@ namespace Cake.Common.Tools.DotNet.VSTest /// /// Contains settings used by . /// - public class DotNetVSTestSettings : DotNetCoreSettings + public class DotNetVSTestSettings : DotNetSettings { /// /// Gets or sets the settings file to use when running tests. diff --git a/src/Cake.Common/Tools/DotNetCore/DotNetCoreRollForward.cs b/src/Cake.Common/Tools/DotNetCore/DotNetCoreRollForward.cs index f007c5f272..18945d69a6 100644 --- a/src/Cake.Common/Tools/DotNetCore/DotNetCoreRollForward.cs +++ b/src/Cake.Common/Tools/DotNetCore/DotNetCoreRollForward.cs @@ -2,41 +2,307 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; +using System.ComponentModel; +using Cake.Common.Tools.DotNet; + namespace Cake.Common.Tools.DotNetCore { /// /// Contains the roll forward policy to be used. /// - public enum DotNetCoreRollForward + [TypeConverter(typeof(DotNetCoreRollForwardConverter))] + public sealed class DotNetCoreRollForward : IEquatable, IComparable, IConvertible, IFormattable { + private readonly DotNetRollForward _value; + + /// + /// Initializes a new instance of the class. + /// + public DotNetCoreRollForward() + { + _value = default; + } + + internal DotNetCoreRollForward(string stringValue) + { + _value = (DotNetRollForward)Enum.Parse(typeof(DotNetRollForward), stringValue); + } + + private DotNetCoreRollForward(DotNetRollForward value) + { + _value = value; + } + /// /// Roll forward to the lowest higher minor version, if requested minor version is missing. /// - Minor, + public static readonly DotNetCoreRollForward Minor = new DotNetCoreRollForward(DotNetRollForward.Minor); /// /// Roll forward to the highest patch version. This disables minor version roll forward. /// - LatestPatch, + public static readonly DotNetCoreRollForward LatestPatch = new DotNetCoreRollForward(DotNetRollForward.LatestPatch); /// /// Roll forward to lowest higher major version, and lowest minor version, if requested major version is missing. /// - Major, + public static readonly DotNetCoreRollForward Major = new DotNetCoreRollForward(DotNetRollForward.Major); /// /// Roll forward to highest minor version, even if requested minor version is present. /// - LatestMinor, + public static readonly DotNetCoreRollForward LatestMinor = new DotNetCoreRollForward(DotNetRollForward.LatestMinor); /// /// Roll forward to highest major and highest minor version, even if requested major is present. /// - LatestMajor, + public static readonly DotNetCoreRollForward LatestMajor = new DotNetCoreRollForward(DotNetRollForward.LatestMajor); /// /// Don't roll forward. Only bind to specified version. /// - Disable, + public static readonly DotNetCoreRollForward Disable = new DotNetCoreRollForward(DotNetRollForward.Disable); + + /// + /// Explicitly converts to . + /// + /// The . + public static explicit operator int(DotNetCoreRollForward rollForward) + { + return (int)rollForward._value; + } + + /// + /// Implicitly converts to . + /// + /// The . + public static implicit operator DotNetRollForward(DotNetCoreRollForward rollForward) + { + return rollForward._value; + } + + /// + /// Implicitly converts to . + /// + /// The . + public static implicit operator DotNetCoreRollForward(DotNetRollForward rollForward) + { + return rollForward switch + { + DotNetRollForward.Minor => Minor, + DotNetRollForward.LatestPatch => LatestPatch, + DotNetRollForward.Major => Major, + DotNetRollForward.LatestMinor => LatestMinor, + DotNetRollForward.LatestMajor => LatestMajor, + DotNetRollForward.Disable => Disable, + _ => new DotNetCoreRollForward(rollForward), + }; + } + + /// + /// Determines whether the specified object is equal to the current object. + /// + /// The object to compare with the right-hand side object. + /// The object to compare with the left-hand side object. + /// if the specified object is equal to the current object; otherwise, . + public static bool operator ==(DotNetCoreRollForward left, DotNetCoreRollForward right) + { + return left.Equals(right); + } + + /// + /// Determines whether the specified object is not equal to the current object. + /// + /// The object to compare with the right-hand side object. + /// The object to compare with the left-hand side object. + /// if the specified object is not equal to the current object; otherwise, . + public static bool operator !=(DotNetCoreRollForward left, DotNetCoreRollForward right) + { + return !(left == right); + } + + /// + public override string ToString() + { + return _value.ToString(); + } + + /// + public override int GetHashCode() + { + return _value.GetHashCode(); + } + + /// + public override bool Equals(object obj) + { + if (obj is null) + { + return false; + } + + if (!(obj is DotNetCoreRollForward)) + { + return false; + } + + return Equals((DotNetCoreRollForward)obj); + } + + /// + public bool Equals(DotNetCoreRollForward other) + { + return _value.Equals(other._value); + } + + /// + /// Determines whether one or more bit fields are set in the current instance. + /// + /// An enumeration value. + /// + /// if the bit field or bit fields that are set in flag are also set in the + /// current instance; otherwise, . + /// + public bool HasFlag(DotNetCoreRollForward flag) + { + return _value.HasFlag(flag._value); + } + + /// + /// Determines whether one or more bit fields are set in the current instance. + /// + /// An enumeration value. + /// + /// if the bit field or bit fields that are set in flag are also set in the + /// current instance; otherwise, . + /// + public bool HasFlag(Enum flag) + { + return _value.HasFlag(flag); + } + + /// + public int CompareTo(object obj) + { + return _value.CompareTo(obj); + } + + /// + public TypeCode GetTypeCode() + { + return Convert.GetTypeCode(_value); + } + + /// + bool IConvertible.ToBoolean(IFormatProvider provider) + { + return Convert.ToBoolean(_value, provider); + } + + /// + byte IConvertible.ToByte(IFormatProvider provider) + { + return Convert.ToByte(_value, provider); + } + + /// + char IConvertible.ToChar(IFormatProvider provider) + { + return Convert.ToChar(_value, provider); + } + + /// + DateTime IConvertible.ToDateTime(IFormatProvider provider) + { + return Convert.ToDateTime(_value, provider); + } + + /// + decimal IConvertible.ToDecimal(IFormatProvider provider) + { + return Convert.ToDecimal(_value, provider); + } + + /// + double IConvertible.ToDouble(IFormatProvider provider) + { + return Convert.ToDouble(_value, provider); + } + + /// + short IConvertible.ToInt16(IFormatProvider provider) + { + return Convert.ToInt16(_value, provider); + } + + /// + int IConvertible.ToInt32(IFormatProvider provider) + { + return Convert.ToInt32(_value, provider); + } + + /// + long IConvertible.ToInt64(IFormatProvider provider) + { + return Convert.ToInt64(_value, provider); + } + + /// +#pragma warning disable CS3002 // Return type is not CLS-compliant + sbyte IConvertible.ToSByte(IFormatProvider provider) +#pragma warning restore CS3002 // Return type is not CLS-compliant + { + return Convert.ToSByte(_value, provider); + } + + /// + float IConvertible.ToSingle(IFormatProvider provider) + { + return Convert.ToSingle(_value, provider); + } + + /// + string IConvertible.ToString(IFormatProvider provider) + { + return Convert.ToString(_value, provider); + } + + /// + object IConvertible.ToType(Type conversionType, IFormatProvider provider) + { + return Convert.ChangeType(_value, conversionType, provider); + } + + /// +#pragma warning disable CS3002 // Return type is not CLS-compliant + ushort IConvertible.ToUInt16(IFormatProvider provider) +#pragma warning restore CS3002 // Return type is not CLS-compliant + { + return Convert.ToUInt16(_value, provider); + } + + /// +#pragma warning disable CS3002 // Return type is not CLS-compliant + uint IConvertible.ToUInt32(IFormatProvider provider) +#pragma warning restore CS3002 // Return type is not CLS-compliant + { + return Convert.ToUInt32(_value, provider); + } + + /// +#pragma warning disable CS3002 // Return type is not CLS-compliant + ulong IConvertible.ToUInt64(IFormatProvider provider) +#pragma warning restore CS3002 // Return type is not CLS-compliant + { + return Convert.ToUInt64(_value, provider); + } + + /// + [Obsolete("The provider argument is not used. Please use ToString(String).")] + public string ToString(string format, IFormatProvider formatProvider) + { + return _value.ToString(format, formatProvider); + } } } diff --git a/src/Cake.Common/Tools/DotNetCore/DotNetCoreRollForwardConverter.cs b/src/Cake.Common/Tools/DotNetCore/DotNetCoreRollForwardConverter.cs new file mode 100644 index 0000000000..9063195e46 --- /dev/null +++ b/src/Cake.Common/Tools/DotNetCore/DotNetCoreRollForwardConverter.cs @@ -0,0 +1,46 @@ +using System; +using System.ComponentModel; +using System.Globalization; + +namespace Cake.Common.Tools.DotNetCore +{ + /// + /// A type converter for . + /// + public class DotNetCoreRollForwardConverter : TypeConverter + { + /// + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); + } + + /// + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + if (value is string stringValue) + { + return new DotNetCoreRollForward(stringValue); + } + + return base.ConvertFrom(context, culture, value); + } + + /// + public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + { + return destinationType == typeof(DotNetCoreRollForward) || base.CanConvertTo(context, destinationType); + } + + /// + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + if (destinationType == typeof(string) && value is DotNetCoreRollForward dotNetRollForwardValue) + { + return dotNetRollForwardValue.ToString(); + } + + return base.ConvertTo(context, culture, value, destinationType); + } + } +} diff --git a/src/Cake.Common/Tools/DotNetCore/DotNetCoreTool.cs b/src/Cake.Common/Tools/DotNetCore/DotNetCoreTool.cs index c8c370ef3c..da15b30cbe 100644 --- a/src/Cake.Common/Tools/DotNetCore/DotNetCoreTool.cs +++ b/src/Cake.Common/Tools/DotNetCore/DotNetCoreTool.cs @@ -14,7 +14,7 @@ namespace Cake.Common.Tools.DotNetCore /// /// The settings type. public abstract class DotNetCoreTool : DotNetTool - where TSettings : DotNetCoreSettings + where TSettings : DotNetSettings { /// /// Initializes a new instance of the class. diff --git a/src/Cake.Common/Tools/DotNetCore/DotNetCoreVerbosity.cs b/src/Cake.Common/Tools/DotNetCore/DotNetCoreVerbosity.cs index c37c459e85..57b0ec9df3 100644 --- a/src/Cake.Common/Tools/DotNetCore/DotNetCoreVerbosity.cs +++ b/src/Cake.Common/Tools/DotNetCore/DotNetCoreVerbosity.cs @@ -2,36 +2,301 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; +using System.ComponentModel; +using Cake.Common.Tools.DotNet; + namespace Cake.Common.Tools.DotNetCore { /// /// Contains the verbosity of logging to use. /// - public enum DotNetCoreVerbosity + [TypeConverter(typeof(DotNetCoreVerbosityConverter))] + public sealed class DotNetCoreVerbosity : IEquatable, IComparable, IConvertible, IFormattable { + private readonly DotNetVerbosity _value; + + /// + /// Initializes a new instance of the class. + /// + public DotNetCoreVerbosity() + { + _value = default; + } + + internal DotNetCoreVerbosity(string stringValue) + { + _value = (DotNetVerbosity)Enum.Parse(typeof(DotNetVerbosity), stringValue); + } + + private DotNetCoreVerbosity(DotNetVerbosity value) + { + _value = value; + } + /// /// Quiet level. /// - Quiet, + public static readonly DotNetCoreVerbosity Quiet = new DotNetCoreVerbosity(DotNetVerbosity.Quiet); /// /// Minimal level. /// - Minimal, + public static readonly DotNetCoreVerbosity Minimal = new DotNetCoreVerbosity(DotNetVerbosity.Minimal); /// /// Normal level. /// - Normal, + public static readonly DotNetCoreVerbosity Normal = new DotNetCoreVerbosity(DotNetVerbosity.Normal); /// /// Detailed level. /// - Detailed, + public static readonly DotNetCoreVerbosity Detailed = new DotNetCoreVerbosity(DotNetVerbosity.Detailed); /// /// Diagnostic level. /// - Diagnostic + public static readonly DotNetCoreVerbosity Diagnostic = new DotNetCoreVerbosity(DotNetVerbosity.Diagnostic); + + /// + /// Explicitly converts to . + /// + /// The . + public static explicit operator int(DotNetCoreVerbosity verbosity) + { + return (int)verbosity._value; + } + + /// + /// Implicitly converts to . + /// + /// The . + public static implicit operator DotNetVerbosity(DotNetCoreVerbosity verbosity) + { + return verbosity._value; + } + + /// + /// Implicitly converts to . + /// + /// The . + public static implicit operator DotNetCoreVerbosity(DotNetVerbosity verbosity) + { + return verbosity switch + { + DotNetVerbosity.Quiet => Quiet, + DotNetVerbosity.Minimal => Minimal, + DotNetVerbosity.Normal => Normal, + DotNetVerbosity.Detailed => Detailed, + DotNetVerbosity.Diagnostic => Diagnostic, + _ => new DotNetCoreVerbosity(verbosity), + }; + } + + /// + /// Determines whether the specified object is equal to the current object. + /// + /// The object to compare with the right-hand side object. + /// The object to compare with the left-hand side object. + /// if the specified object is equal to the current object; otherwise, . + public static bool operator ==(DotNetCoreVerbosity left, DotNetCoreVerbosity right) + { + return left.Equals(right); + } + + /// + /// Determines whether the specified object is not equal to the current object. + /// + /// The object to compare with the right-hand side object. + /// The object to compare with the left-hand side object. + /// if the specified object is not equal to the current object; otherwise, . + public static bool operator !=(DotNetCoreVerbosity left, DotNetCoreVerbosity right) + { + return !(left == right); + } + + /// + public override string ToString() + { + return _value.ToString(); + } + + /// + public override int GetHashCode() + { + return _value.GetHashCode(); + } + + /// + public override bool Equals(object obj) + { + if (obj is null) + { + return false; + } + + if (!(obj is DotNetCoreVerbosity)) + { + return false; + } + + return Equals((DotNetCoreVerbosity)obj); + } + + /// + public bool Equals(DotNetCoreVerbosity other) + { + return _value.Equals(other._value); + } + + /// + /// Determines whether one or more bit fields are set in the current instance. + /// + /// An enumeration value. + /// + /// if the bit field or bit fields that are set in flag are also set in the + /// current instance; otherwise, . + /// + public bool HasFlag(DotNetCoreVerbosity flag) + { + return _value.HasFlag(flag._value); + } + + /// + /// Determines whether one or more bit fields are set in the current instance. + /// + /// An enumeration value. + /// + /// if the bit field or bit fields that are set in flag are also set in the + /// current instance; otherwise, . + /// + public bool HasFlag(Enum flag) + { + return _value.HasFlag(flag); + } + + /// + public int CompareTo(object obj) + { + return _value.CompareTo(obj); + } + + /// + public TypeCode GetTypeCode() + { + return Convert.GetTypeCode(_value); + } + + /// + bool IConvertible.ToBoolean(IFormatProvider provider) + { + return Convert.ToBoolean(_value, provider); + } + + /// + byte IConvertible.ToByte(IFormatProvider provider) + { + return Convert.ToByte(_value, provider); + } + + /// + char IConvertible.ToChar(IFormatProvider provider) + { + return Convert.ToChar(_value, provider); + } + + /// + DateTime IConvertible.ToDateTime(IFormatProvider provider) + { + return Convert.ToDateTime(_value, provider); + } + + /// + decimal IConvertible.ToDecimal(IFormatProvider provider) + { + return Convert.ToDecimal(_value, provider); + } + + /// + double IConvertible.ToDouble(IFormatProvider provider) + { + return Convert.ToDouble(_value, provider); + } + + /// + short IConvertible.ToInt16(IFormatProvider provider) + { + return Convert.ToInt16(_value, provider); + } + + /// + int IConvertible.ToInt32(IFormatProvider provider) + { + return Convert.ToInt32(_value, provider); + } + + /// + long IConvertible.ToInt64(IFormatProvider provider) + { + return Convert.ToInt64(_value, provider); + } + + /// +#pragma warning disable CS3002 // Return type is not CLS-compliant + sbyte IConvertible.ToSByte(IFormatProvider provider) +#pragma warning restore CS3002 // Return type is not CLS-compliant + { + return Convert.ToSByte(_value, provider); + } + + /// + float IConvertible.ToSingle(IFormatProvider provider) + { + return Convert.ToSingle(_value, provider); + } + + /// + string IConvertible.ToString(IFormatProvider provider) + { + return Convert.ToString(_value, provider); + } + + /// + object IConvertible.ToType(Type conversionType, IFormatProvider provider) + { + return Convert.ChangeType(_value, conversionType, provider); + } + + /// +#pragma warning disable CS3002 // Return type is not CLS-compliant + ushort IConvertible.ToUInt16(IFormatProvider provider) +#pragma warning restore CS3002 // Return type is not CLS-compliant + { + return Convert.ToUInt16(_value, provider); + } + + /// +#pragma warning disable CS3002 // Return type is not CLS-compliant + uint IConvertible.ToUInt32(IFormatProvider provider) +#pragma warning restore CS3002 // Return type is not CLS-compliant + { + return Convert.ToUInt32(_value, provider); + } + + /// +#pragma warning disable CS3002 // Return type is not CLS-compliant + ulong IConvertible.ToUInt64(IFormatProvider provider) +#pragma warning restore CS3002 // Return type is not CLS-compliant + { + return Convert.ToUInt64(_value, provider); + } + + /// + [Obsolete("The provider argument is not used. Please use ToString(String).")] + public string ToString(string format, IFormatProvider formatProvider) + { + return _value.ToString(format, formatProvider); + } } } diff --git a/src/Cake.Common/Tools/DotNetCore/DotNetCoreVerbosityConverter.cs b/src/Cake.Common/Tools/DotNetCore/DotNetCoreVerbosityConverter.cs new file mode 100644 index 0000000000..c3b3793de1 --- /dev/null +++ b/src/Cake.Common/Tools/DotNetCore/DotNetCoreVerbosityConverter.cs @@ -0,0 +1,46 @@ +using System; +using System.ComponentModel; +using System.Globalization; + +namespace Cake.Common.Tools.DotNetCore +{ + /// + /// A type converter for . + /// + public class DotNetCoreVerbosityConverter : TypeConverter + { + /// + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); + } + + /// + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + if (value is string stringValue) + { + return new DotNetCoreVerbosity(stringValue); + } + + return base.ConvertFrom(context, culture, value); + } + + /// + public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + { + return destinationType == typeof(DotNetCoreVerbosity) || base.CanConvertTo(context, destinationType); + } + + /// + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + if (destinationType == typeof(string) && value is DotNetCoreVerbosity dotNetVerbosityValue) + { + return dotNetVerbosityValue.ToString(); + } + + return base.ConvertTo(context, culture, value, destinationType); + } + } +} diff --git a/src/Cake.Common/Tools/DotNetCore/MSBuild/MSBuildLoggerSettings.cs b/src/Cake.Common/Tools/DotNetCore/MSBuild/MSBuildLoggerSettings.cs index 3594fcc4a5..c63abb49e2 100644 --- a/src/Cake.Common/Tools/DotNetCore/MSBuild/MSBuildLoggerSettings.cs +++ b/src/Cake.Common/Tools/DotNetCore/MSBuild/MSBuildLoggerSettings.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Cake.Common.Tools.DotNet; + namespace Cake.Common.Tools.DotNetCore.MSBuild { /// @@ -63,6 +65,6 @@ public class MSBuildLoggerSettings /// /// Gets or sets a value that overrides the /verbosity setting for this logger. /// - public DotNetCoreVerbosity? Verbosity { get; set; } + public DotNetVerbosity? Verbosity { get; set; } } } \ No newline at end of file diff --git a/src/Cake.Common/Tools/DotNetCore/Tool/DotNetCoreToolRunner.cs b/src/Cake.Common/Tools/DotNetCore/Tool/DotNetCoreToolRunner.cs index 84ee744d53..caa8eb5acd 100644 --- a/src/Cake.Common/Tools/DotNetCore/Tool/DotNetCoreToolRunner.cs +++ b/src/Cake.Common/Tools/DotNetCore/Tool/DotNetCoreToolRunner.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using Cake.Common.Tools.DotNet; using Cake.Common.Tools.DotNet.Tool; using Cake.Core; using Cake.Core.IO; @@ -13,7 +14,7 @@ namespace Cake.Common.Tools.DotNetCore.Tool /// /// .NET Core Extensibility Commands Runner. /// - public sealed class DotNetCoreToolRunner : DotNetCoreTool + public sealed class DotNetCoreToolRunner : DotNetCoreTool { private readonly ICakeEnvironment _environment; diff --git a/src/Cake.Core.Tests/Fixtures/ScriptRunnerFixture.cs b/src/Cake.Core.Tests/Fixtures/ScriptRunnerFixture.cs index c82a17019f..c59f1518df 100644 --- a/src/Cake.Core.Tests/Fixtures/ScriptRunnerFixture.cs +++ b/src/Cake.Core.Tests/Fixtures/ScriptRunnerFixture.cs @@ -58,9 +58,11 @@ public ScriptRunnerFixture(string fileName = "/Working/build.cake") Engine.CreateSession(Arg.Any()).Returns(Session); var runtime = new CakeRuntime(); + var referenceAssemblyResolver = Substitute.For(); + referenceAssemblyResolver.GetReferenceAssemblies().Returns(Array.Empty()); ScriptAnalyzer = new ScriptAnalyzer(FileSystem, Environment, Log, new[] { new FileLoadDirectiveProvider(Globber, Log) }); ScriptProcessor = Substitute.For(); - ScriptConventions = new ScriptConventions(FileSystem, AssemblyLoader, runtime); + ScriptConventions = new ScriptConventions(FileSystem, AssemblyLoader, runtime, referenceAssemblyResolver); var context = Substitute.For(); context.Environment.Returns(c => Environment); diff --git a/src/Cake.Core/Scripting/IReferenceAssemblyResolver.cs b/src/Cake.Core/Scripting/IReferenceAssemblyResolver.cs new file mode 100644 index 0000000000..3e5a2a4f42 --- /dev/null +++ b/src/Cake.Core/Scripting/IReferenceAssemblyResolver.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Reflection; + +namespace Cake.Core.Scripting +{ + /// + /// Represents a framework reference assembly resolver. + /// + public interface IReferenceAssemblyResolver + { + /// + /// Finds framwork reference assemblies. + /// + /// The resolved reference assemblies. + Assembly[] GetReferenceAssemblies(); + } +} \ No newline at end of file diff --git a/src/Cake.Core/Scripting/ScriptConventions.cs b/src/Cake.Core/Scripting/ScriptConventions.cs index 979ca37296..d3e146d103 100644 --- a/src/Cake.Core/Scripting/ScriptConventions.cs +++ b/src/Cake.Core/Scripting/ScriptConventions.cs @@ -20,6 +20,7 @@ public sealed class ScriptConventions : IScriptConventions private readonly IFileSystem _fileSystem; private readonly IAssemblyLoader _loader; private readonly ICakeRuntime _runtime; + private readonly IReferenceAssemblyResolver _referenceAssemblyResolver; /// /// Initializes a new instance of the class. @@ -27,11 +28,13 @@ public sealed class ScriptConventions : IScriptConventions /// The file system. /// The assembly loader. /// The Cake runtime. - public ScriptConventions(IFileSystem fileSystem, IAssemblyLoader loader, ICakeRuntime runtime) + /// The reference assembly resolver. + public ScriptConventions(IFileSystem fileSystem, IAssemblyLoader loader, ICakeRuntime runtime, IReferenceAssemblyResolver referenceAssemblyResolver) { _fileSystem = fileSystem; _loader = loader; _runtime = runtime; + _referenceAssemblyResolver = referenceAssemblyResolver; } /// @@ -61,6 +64,8 @@ public IReadOnlyList GetDefaultAssemblies(DirectoryPath root) result.Add(typeof(IQueryable).GetTypeInfo().Assembly); // System.Core or System.Linq.Expressions result.Add(typeof(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo).Assembly); // Dynamic support + result.AddRange(_referenceAssemblyResolver.GetReferenceAssemblies()); + // Load other Cake-related assemblies that we need. var cakeAssemblies = LoadCakeAssemblies(root); result.AddRange(cakeAssemblies); diff --git a/src/Cake.DotNetTool.Module/Cake.DotNetTool.Module.csproj b/src/Cake.DotNetTool.Module/Cake.DotNetTool.Module.csproj index de8e466f32..180575503a 100644 --- a/src/Cake.DotNetTool.Module/Cake.DotNetTool.Module.csproj +++ b/src/Cake.DotNetTool.Module/Cake.DotNetTool.Module.csproj @@ -4,6 +4,7 @@ true true snupkg + $(PackageTags);dotnettool;module;cake-build;cake-module Cake.DotNetTool.Module.ruleset diff --git a/src/Cake.Frosting/Cake.Frosting.csproj b/src/Cake.Frosting/Cake.Frosting.csproj index 2055e3edba..ff0866174f 100644 --- a/src/Cake.Frosting/Cake.Frosting.csproj +++ b/src/Cake.Frosting/Cake.Frosting.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/Cake.Frosting/Internal/TypeResolver.cs b/src/Cake.Frosting/Internal/TypeResolver.cs index fe3c871017..0ba5b070ed 100644 --- a/src/Cake.Frosting/Internal/TypeResolver.cs +++ b/src/Cake.Frosting/Internal/TypeResolver.cs @@ -18,6 +18,11 @@ public TypeResolver(IServiceProvider provider) public object Resolve(Type type) { + if (type == null) + { + return null; + } + return _provider.GetService(type); } } diff --git a/src/Cake.NuGet/Cake.NuGet.csproj b/src/Cake.NuGet/Cake.NuGet.csproj index 772e959442..93167d92a0 100644 --- a/src/Cake.NuGet/Cake.NuGet.csproj +++ b/src/Cake.NuGet/Cake.NuGet.csproj @@ -29,7 +29,7 @@ - + All diff --git a/src/Cake/Cake.csproj b/src/Cake/Cake.csproj index a4955d0e0d..6525339ef5 100644 --- a/src/Cake/Cake.csproj +++ b/src/Cake/Cake.csproj @@ -26,9 +26,12 @@ - - - + + + + + + \ No newline at end of file diff --git a/src/Cake/Infrastructure/Composition/AutofacTypeResolver.cs b/src/Cake/Infrastructure/Composition/AutofacTypeResolver.cs index 0442d82fad..1eef53357c 100644 --- a/src/Cake/Infrastructure/Composition/AutofacTypeResolver.cs +++ b/src/Cake/Infrastructure/Composition/AutofacTypeResolver.cs @@ -19,7 +19,12 @@ public AutofacTypeResolver(ILifetimeScope scope) public object Resolve(Type type) { - return _scope.Resolve(type); + if (type == null) + { + return null; + } + + return _scope.ResolveOptional(type); } } } diff --git a/src/Cake/Infrastructure/ContainerConfigurator.cs b/src/Cake/Infrastructure/ContainerConfigurator.cs index 236e5eae8a..0a08012569 100644 --- a/src/Cake/Infrastructure/ContainerConfigurator.cs +++ b/src/Cake/Infrastructure/ContainerConfigurator.cs @@ -33,6 +33,7 @@ public void Configure( registrar.RegisterType().Singleton(); registrar.RegisterType().Singleton(); registrar.RegisterType().Singleton(); + registrar.RegisterType().As().Singleton(); // Diagnostics registrar.RegisterType().As().Singleton(); diff --git a/src/Cake/Infrastructure/Scripting/ReferenceAssemblyResolver.cs b/src/Cake/Infrastructure/Scripting/ReferenceAssemblyResolver.cs new file mode 100644 index 0000000000..d420818f87 --- /dev/null +++ b/src/Cake/Infrastructure/Scripting/ReferenceAssemblyResolver.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Cake.Core.Diagnostics; +using Cake.Core.Scripting; + +namespace Cake.Infrastructure.Scripting +{ + public sealed class ReferenceAssemblyResolver : IReferenceAssemblyResolver + { + private readonly ICakeLog _log; + + public ReferenceAssemblyResolver(ICakeLog log) + { + _log = log; + } + + public Assembly[] GetReferenceAssemblies() + { + IEnumerable TryGetReferenceAssemblies() + { + foreach (var reference in +#if NETCOREAPP3_1 + Basic.Reference.Assemblies.NetCoreApp31.All) +#elif NET5_0 + Basic.Reference.Assemblies.Net50.All) +#else + Basic.Reference.Assemblies.Net60.All) +#endif + { + Assembly assembly; + try + { + assembly = Assembly.Load(System.IO.Path.GetFileNameWithoutExtension(reference.FilePath)); + } + catch (Exception ex) + { + _log.Debug(log => log("Failed to load {0}\r\n{1}", reference.FilePath, ex)); + continue; + } + + if (assembly == null) + { + continue; + } + + yield return assembly; + + foreach (var assemblyRefName in assembly.GetReferencedAssemblies()) + { + Assembly assemblyRef; + try + { + assemblyRef = Assembly.Load(assemblyRefName); + } + catch (Exception ex) + { + _log.Debug(log => log("Failed to load {0}\r\n{1}", reference.FilePath, ex)); + continue; + } + + if (assemblyRef == null) + { + continue; + } + + yield return assemblyRef; + } + } + } + + return TryGetReferenceAssemblies().ToArray(); + } + } +} diff --git a/src/Cake/Infrastructure/Scripting/ScriptAssemblyResolver.cs b/src/Cake/Infrastructure/Scripting/ScriptAssemblyResolver.cs index a96b39b127..e9406473d9 100644 --- a/src/Cake/Infrastructure/Scripting/ScriptAssemblyResolver.cs +++ b/src/Cake/Infrastructure/Scripting/ScriptAssemblyResolver.cs @@ -55,7 +55,7 @@ private Assembly AssemblyResolve(object sender, ResolveEventArgs args) return null; } - _log.Verbose($"Resolving assembly '{fullName}' using runtime installed at '{RuntimeEnvironment.GetRuntimeDirectory()}'..."); + _log.Debug($"Resolving assembly '{fullName}' using runtime installed at '{RuntimeEnvironment.GetRuntimeDirectory()}'..."); return AssemblyResolve(assemblyName); } @@ -76,12 +76,12 @@ private Assembly AssemblyResolve(AssemblyName assemblyName) } catch (Exception ex) { - _log.Verbose($"Exception occurred while resolving assembly {shortName}: {ex.Message}"); + _log.Debug($"Exception occurred while resolving assembly {shortName}: {ex.Message}"); } if (assembly != null) { - _log.Verbose($"Assembly {shortName} resolved as '{assembly.FullName}' (file location: '{assembly.Location}')"); + _log.Debug($"Assembly {shortName} resolved as '{assembly.FullName}' (file location: '{assembly.Location}')"); return assembly; } @@ -92,12 +92,12 @@ private Assembly AssemblyResolve(AssemblyName assemblyName) { assemblyName.Name = shortName.Remove(shortName.Length - AssemblyResourcesExtension.Length); - _log.Verbose($"Trying to resolve assembly {shortName} as '{assemblyName.FullName}'..."); + _log.Debug($"Trying to resolve assembly {shortName} as '{assemblyName.FullName}'..."); return AssemblyResolve(assemblyName); } } - _log.Verbose($"Assembly '{fullName}' not resolved"); + _log.Debug($"Assembly '{fullName}' not resolved"); return null; } diff --git a/src/Cake/Program.cs b/src/Cake/Program.cs index c0ef00e958..abe894568d 100644 --- a/src/Cake/Program.cs +++ b/src/Cake/Program.cs @@ -71,6 +71,9 @@ private ITypeRegistrar BuildTypeRegistrar() { var builder = new ContainerBuilder(); + // Commands + builder.RegisterType(); + // Converters builder.RegisterType(); builder.RegisterType(); diff --git a/src/SolutionInfo.cs b/src/SolutionInfo.cs index 37a08c93a7..d2ee882ab4 100644 --- a/src/SolutionInfo.cs +++ b/src/SolutionInfo.cs @@ -10,7 +10,7 @@ using System.Reflection; [assembly: AssemblyProduct("Cake")] -[assembly: AssemblyVersion("1.3.0.0")] -[assembly: AssemblyFileVersion("1.3.0.0")] -[assembly: AssemblyInformationalVersion("1.3.0+Branch.release-1.3.0.Sha.77c2a6b82e76905be7f6b76419367191f16c1469")] +[assembly: AssemblyVersion("2.0.0.0")] +[assembly: AssemblyFileVersion("2.0.0.0")] +[assembly: AssemblyInformationalVersion("2.0.0-beta.1+29.Branch.release-2.0.0-rc0002.Sha.0c17e1d2547252c226c8ebb205db18790f2459a5")] [assembly: AssemblyCopyright("Copyright (c) .NET Foundation and Contributors")] diff --git a/tests/integration/Cake.Common/ArgumentAliases.cake b/tests/integration/Cake.Common/ArgumentAliases.cake index 5b5a2ce83a..be80aa8f63 100644 --- a/tests/integration/Cake.Common/ArgumentAliases.cake +++ b/tests/integration/Cake.Common/ArgumentAliases.cake @@ -50,7 +50,46 @@ Task("Cake.Common.ArgumentAliases.Argument.MultipleArguments") var arg = Arguments("multipleargs"); // Then - Assert.Equal(new[] {"a", "b"}, arg); + Assert.Equal(new[] { "a", "b" }, arg); +}); + +Task("Cake.Common.ArgumentAliases.Argument.MultipleArguments.WithSingleDefaultValue") + .Does(() => +{ + // Given + var expect = new[] { "a" }; + + // When + var arg = Arguments("nonexistingmultipleargs", expect[0]); + + // Then + Assert.Equal(expect, arg); +}); + +Task("Cake.Common.ArgumentAliases.Argument.MultipleArguments.WithMultipleDefaultValue") + .Does(() => +{ + // Given + var expect = new[] { "a", "b" }; + + // When + var arg = Arguments("nonexistingmultipleargs", expect); + + // Then + Assert.Equal(expect, arg); +}); + +Task("Cake.Common.ArgumentAliases.Argument.MultipleArguments.WithLazyDefaultValue") + .Does(() => +{ + // Given + var expect = new[] { "a", "b" }; + + // When + var arg = Arguments("nonexistingmultipleargs", _ => expect); + + // Then + Assert.Equal(expect, arg); }); Task("Cake.Common.ArgumentAliases.Argument.DirectoryPathArgument") @@ -79,6 +118,26 @@ Task("Cake.Common.ArgumentAliases.Argument.FilePathArgument") Assert.Equal(testAssemblyPath.FullPath, arg.FullPath); }); +Task("Cake.Common.ArgumentAliases.Argument.DotNetCoreVerbosityArgument") + .Does(() => +{ + // Given, When + var arg = Argument("testDotNetCoreVerbosity"); + + // Then + Assert.Equal(DotNetCoreVerbosity.Diagnostic, arg); +}); + +Task("Cake.Common.ArgumentAliases.Argument.DotNetCoreRollForwardArgument") + .Does(() => +{ + // Given, When + var arg = Argument("testDotNetRollForward"); + + // Then + Assert.Equal(DotNetCoreRollForward.LatestMajor, arg); +}); + ////////////////////////////////////////////////////////////////////////////// Task("Cake.Common.ArgumentAliases") @@ -87,6 +146,11 @@ Task("Cake.Common.ArgumentAliases") .IsDependentOn("Cake.Common.ArgumentAliases.Argument") .IsDependentOn("Cake.Common.ArgumentAliases.Argument.WithDefaultValue") .IsDependentOn("Cake.Common.ArgumentAliases.Argument.MultipleArguments") + .IsDependentOn("Cake.Common.ArgumentAliases.Argument.MultipleArguments.WithSingleDefaultValue") + .IsDependentOn("Cake.Common.ArgumentAliases.Argument.MultipleArguments.WithMultipleDefaultValue") + .IsDependentOn("Cake.Common.ArgumentAliases.Argument.MultipleArguments.WithLazyDefaultValue") .IsDependentOn("Cake.Common.ArgumentAliases.Argument.DirectoryPathArgument") .IsDependentOn("Cake.Common.ArgumentAliases.Argument.FilePathArgument") + .IsDependentOn("Cake.Common.ArgumentAliases.Argument.DotNetCoreVerbosityArgument") + .IsDependentOn("Cake.Common.ArgumentAliases.Argument.DotNetCoreRollForwardArgument") ; diff --git a/tests/integration/Cake.Common/Tools/DotNet/DotNetAliases.cake b/tests/integration/Cake.Common/Tools/DotNet/DotNetAliases.cake index 9a3cac5b64..1db1ed92d3 100644 --- a/tests/integration/Cake.Common/Tools/DotNet/DotNetAliases.cake +++ b/tests/integration/Cake.Common/Tools/DotNet/DotNetAliases.cake @@ -239,7 +239,7 @@ Task("Cake.Common.Tools.DotNet.DotNetAliases.DotNetTest.Fail") // Then Assert.NotNull(exception); Assert.IsType(exception); - Assert.Equal(exception.Message, ".NET Core CLI: Process returned an error (exit code 1)."); + Assert.Equal(exception.Message, ".NET CLI: Process returned an error (exit code 1)."); }); diff --git a/tests/integration/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cake b/tests/integration/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cake index 434b77c3d7..10b3094451 100644 --- a/tests/integration/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cake +++ b/tests/integration/Cake.Common/Tools/DotNetCore/DotNetCoreAliases.cake @@ -239,7 +239,7 @@ Task("Cake.Common.Tools.DotNetCore.DotNetCoreAliases.DotNetCoreTest.Fail") // Then Assert.NotNull(exception); Assert.IsType(exception); - Assert.Equal(exception.Message, ".NET Core CLI: Process returned an error (exit code 1)."); + Assert.Equal(exception.Message, ".NET CLI: Process returned an error (exit code 1)."); });