diff --git a/src/Cake.Common.Tests/Unit/Build/BuildSystemTests.cs b/src/Cake.Common.Tests/Unit/Build/BuildSystemTests.cs index 942c9f53de..1c93f2054c 100644 --- a/src/Cake.Common.Tests/Unit/Build/BuildSystemTests.cs +++ b/src/Cake.Common.Tests/Unit/Build/BuildSystemTests.cs @@ -733,76 +733,6 @@ public void Should_Return_True_If_Running_On_GitLabCI() } } - public sealed class TheIsRunningOnTFSProperty - { - [Fact] - public void Should_Return_True_If_Running_On_TFS() - { - // Given - var appVeyorProvider = Substitute.For(); - var teamCityProvider = Substitute.For(); - var myGetProvider = Substitute.For(); - var bambooProvider = Substitute.For(); - var continuaCIProvider = Substitute.For(); - var jenkinsProvider = Substitute.For(); - var bitriseProvider = Substitute.For(); - var travisCIProvider = Substitute.For(); - var bitbucketPipelinesProvider = Substitute.For(); - var goCDProvider = Substitute.For(); - var gitLabCIProvider = Substitute.For(); - var tfBuildProvider = Substitute.For(); - var tfBuildEnvironment = new TFBuildInfoFixture().CreateEnvironmentInfo(); - var gitHubActionsProvider = Substitute.For(); - var azurePipelinesProvider = Substitute.For(); - -#pragma warning disable 618 - tfBuildProvider.IsRunningOnTFS.Returns(true); - tfBuildProvider.Environment.Returns(tfBuildEnvironment); - - // When - var buildSystem = new BuildSystem(appVeyorProvider, teamCityProvider, myGetProvider, bambooProvider, continuaCIProvider, jenkinsProvider, bitriseProvider, travisCIProvider, bitbucketPipelinesProvider, goCDProvider, gitLabCIProvider, tfBuildProvider, gitHubActionsProvider, azurePipelinesProvider); - - // Then - Assert.True(buildSystem.IsRunningOnTFS); -#pragma warning restore 618 - } - } - - public sealed class TheIsRunningOnVSTSProperty - { - [Fact] - public void Should_Return_True_If_Running_On_VSTS() - { - // Given - var appVeyorProvider = Substitute.For(); - var teamCityProvider = Substitute.For(); - var myGetProvider = Substitute.For(); - var bambooProvider = Substitute.For(); - var continuaCIProvider = Substitute.For(); - var jenkinsProvider = Substitute.For(); - var bitriseProvider = Substitute.For(); - var travisCIProvider = Substitute.For(); - var bitbucketPipelinesProvider = Substitute.For(); - var goCDProvider = Substitute.For(); - var gitLabCIProvider = Substitute.For(); - var tfBuildProvider = Substitute.For(); - var tfBuildEnvironment = new TFBuildInfoFixture().CreateEnvironmentInfo(); - var gitHubActionsProvider = Substitute.For(); - var azurePipelinesProvider = Substitute.For(); - -#pragma warning disable 618 - tfBuildProvider.IsRunningOnVSTS.Returns(true); - tfBuildProvider.Environment.Returns(tfBuildEnvironment); - - // When - var buildSystem = new BuildSystem(appVeyorProvider, teamCityProvider, myGetProvider, bambooProvider, continuaCIProvider, jenkinsProvider, bitriseProvider, travisCIProvider, bitbucketPipelinesProvider, goCDProvider, gitLabCIProvider, tfBuildProvider, gitHubActionsProvider, azurePipelinesProvider); - - // Then - Assert.True(buildSystem.IsRunningOnVSTS); -#pragma warning restore 618 - } - } - public sealed class TheIsRunningOnAzurePipelinesProperty { [Fact] @@ -911,24 +841,22 @@ public void Should_Return_True_If_Running_On_GitHubActions() public sealed class TheProviderProperty { [Theory] - [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, BuildProvider.Local)] - [InlineData(true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, BuildProvider.AppVeyor)] - [InlineData(false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, BuildProvider.TeamCity)] - [InlineData(false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, BuildProvider.MyGet)] - [InlineData(false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, BuildProvider.Bamboo)] - [InlineData(false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, BuildProvider.ContinuaCI)] - [InlineData(false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, BuildProvider.Jenkins)] - [InlineData(false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, BuildProvider.Bitrise)] - [InlineData(false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, BuildProvider.TravisCI)] - [InlineData(false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, BuildProvider.BitbucketPipelines)] - [InlineData(false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, BuildProvider.GoCD)] - [InlineData(false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, BuildProvider.GitLabCI)] - [InlineData(false, false, false, false, false, false, false, false, false, false, false, true, false, true, false, false, BuildProvider.AzurePipelines)] // tfs - [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, true, false, true, false, BuildProvider.AzurePipelinesHosted)] // vsts - [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, BuildProvider.AzurePipelines)] - [InlineData(false, false, false, false, false, false, false, false, false, false, false, true, false, false, true, false, BuildProvider.AzurePipelinesHosted)] - [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, BuildProvider.GitHubActions)] - public void Should_Return_Provider_If_Running_On_Provider(bool appVeyor, bool teamCity, bool myGet, bool bamboo, bool continuaCI, bool jenkins, bool bitrise, bool travisCI, bool bitbucketPipelines, bool goCD, bool gitLabCI, bool tfs, bool vsts, bool azurePipelines, bool azurePipelinesHosted, bool gitHubActions, BuildProvider provider) + [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, false, false, BuildProvider.Local)] + [InlineData(true, false, false, false, false, false, false, false, false, false, false, false, false, false, BuildProvider.AppVeyor)] + [InlineData(false, true, false, false, false, false, false, false, false, false, false, false, false, false, BuildProvider.TeamCity)] + [InlineData(false, false, true, false, false, false, false, false, false, false, false, false, false, false, BuildProvider.MyGet)] + [InlineData(false, false, false, true, false, false, false, false, false, false, false, false, false, false, BuildProvider.Bamboo)] + [InlineData(false, false, false, false, true, false, false, false, false, false, false, false, false, false, BuildProvider.ContinuaCI)] + [InlineData(false, false, false, false, false, true, false, false, false, false, false, false, false, false, BuildProvider.Jenkins)] + [InlineData(false, false, false, false, false, false, true, false, false, false, false, false, false, false, BuildProvider.Bitrise)] + [InlineData(false, false, false, false, false, false, false, true, false, false, false, false, false, false, BuildProvider.TravisCI)] + [InlineData(false, false, false, false, false, false, false, false, true, false, false, false, false, false, BuildProvider.BitbucketPipelines)] + [InlineData(false, false, false, false, false, false, false, false, false, true, false, false, false, false, BuildProvider.GoCD)] + [InlineData(false, false, false, false, false, false, false, false, false, false, true, false, false, false, BuildProvider.GitLabCI)] + [InlineData(false, false, false, false, false, false, false, false, false, false, false, true, false, false, BuildProvider.AzurePipelines)] + [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, true, false, BuildProvider.AzurePipelinesHosted)] + [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, false, true, BuildProvider.GitHubActions)] + public void Should_Return_Provider_If_Running_On_Provider(bool appVeyor, bool teamCity, bool myGet, bool bamboo, bool continuaCI, bool jenkins, bool bitrise, bool travisCI, bool bitbucketPipelines, bool goCD, bool gitLabCI, bool azurePipelines, bool azurePipelinesHosted, bool gitHubActions, BuildProvider provider) { // Given var appVeyorProvider = Substitute.For(); @@ -974,10 +902,6 @@ public void Should_Return_Provider_If_Running_On_Provider(bool appVeyor, bool te goCDProvider.IsRunningOnGoCD.Returns(goCD); gitLabCIProvider.IsRunningOnGitLabCI.Returns(gitLabCI); gitLabCIProvider.Environment.Returns(gitLabCIEnvironment); -#pragma warning disable 618 - tfBuildProvider.IsRunningOnTFS.Returns(tfs); - tfBuildProvider.IsRunningOnVSTS.Returns(vsts); -#pragma warning restore 618 tfBuildProvider.IsRunningOnAzurePipelines.Returns(azurePipelines); tfBuildProvider.IsRunningOnAzurePipelinesHosted.Returns(azurePipelinesHosted); tfBuildProvider.Environment.Returns(tfBuildEnvironment); @@ -998,24 +922,22 @@ public void Should_Return_Provider_If_Running_On_Provider(bool appVeyor, bool te public sealed class TheIsLocalBuildProperty { [Theory] - [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true)] - [InlineData(true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false)] - [InlineData(false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false)] - [InlineData(false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false)] - [InlineData(false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false)] - [InlineData(false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false)] - [InlineData(false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false)] - [InlineData(false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false)] - [InlineData(false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false)] - [InlineData(false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false)] - [InlineData(false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false)] - [InlineData(false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false)] - [InlineData(false, false, false, false, false, false, false, false, false, false, false, true, false, true, false, false, false)] // tfs - [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, true, false, true, false, false)] // vsts - [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false)] - [InlineData(false, false, false, false, false, false, false, false, false, false, false, true, false, false, true, false, false)] - [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false)] - public void Should_Return_False_If_Running_On_Provider(bool appVeyor, bool teamCity, bool myGet, bool bamboo, bool continuaCI, bool jenkins, bool bitrise, bool travisCI, bool bitbucketPipelines, bool goCD, bool gitLabCI, bool tfs, bool vsts, bool azurePipelines, bool azurePipelinesHosted, bool gitHubActions, bool isLocalBuild) + [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, false, false, true)] + [InlineData(true, false, false, false, false, false, false, false, false, false, false, false, false, false, false)] + [InlineData(false, true, false, false, false, false, false, false, false, false, false, false, false, false, false)] + [InlineData(false, false, true, false, false, false, false, false, false, false, false, false, false, false, false)] + [InlineData(false, false, false, true, false, false, false, false, false, false, false, false, false, false, false)] + [InlineData(false, false, false, false, true, false, false, false, false, false, false, false, false, false, false)] + [InlineData(false, false, false, false, false, true, false, false, false, false, false, false, false, false, false)] + [InlineData(false, false, false, false, false, false, true, false, false, false, false, false, false, false, false)] + [InlineData(false, false, false, false, false, false, false, true, false, false, false, false, false, false, false)] + [InlineData(false, false, false, false, false, false, false, false, true, false, false, false, false, false, false)] + [InlineData(false, false, false, false, false, false, false, false, false, true, false, false, false, false, false)] + [InlineData(false, false, false, false, false, false, false, false, false, false, true, false, false, false, false)] + [InlineData(false, false, false, false, false, false, false, false, false, false, false, true, false, false, false)] + [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, true, false, false)] + [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, false, true, false)] + public void Should_Return_Whether_Or_Not_Running_On_Provider(bool appVeyor, bool teamCity, bool myGet, bool bamboo, bool continuaCI, bool jenkins, bool bitrise, bool travisCI, bool bitbucketPipelines, bool goCD, bool gitLabCI, bool azurePipelines, bool azurePipelinesHosted, bool gitHubActions, bool isLocalBuild) { // Given var appVeyorProvider = Substitute.For(); @@ -1061,10 +983,6 @@ public void Should_Return_False_If_Running_On_Provider(bool appVeyor, bool teamC goCDProvider.IsRunningOnGoCD.Returns(goCD); gitLabCIProvider.IsRunningOnGitLabCI.Returns(gitLabCI); gitLabCIProvider.Environment.Returns(gitLabCIEnvironment); -#pragma warning disable 618 - tfBuildProvider.IsRunningOnTFS.Returns(tfs); - tfBuildProvider.IsRunningOnVSTS.Returns(vsts); -#pragma warning restore 618 tfBuildProvider.IsRunningOnAzurePipelines.Returns(azurePipelines); tfBuildProvider.IsRunningOnAzurePipelinesHosted.Returns(azurePipelinesHosted); tfBuildProvider.Environment.Returns(tfBuildEnvironment); @@ -1086,24 +1004,22 @@ public void Should_Return_False_If_Running_On_Provider(bool appVeyor, bool teamC public sealed class TheIsPullRequestProperty { [Theory] - [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false)] // none - [InlineData(true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true)] // appveyor - [InlineData(false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true)] // teamcity - [InlineData(false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false)] // myget - [InlineData(false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false)] // bamboo - [InlineData(false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false)] // continua - [InlineData(false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, true)] // jenkins - [InlineData(false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, true)] // bitrise - [InlineData(false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, true)] // travis - [InlineData(false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, true)] // bitbucket - [InlineData(false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false)] // gocd - [InlineData(false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, true)] // gitlab - [InlineData(false, false, false, false, false, false, false, false, false, false, false, true, false, true, false, false, true)] // tfs - [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, true, false, true, false, true)] // vsts - [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, true)] // az pipelines - [InlineData(false, false, false, false, false, false, false, false, false, false, false, true, false, false, true, false, true)] // az pipelines hosted - [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true)] // gh actions - public void Should_Return_True_If_Running_On_Supported_Provider(bool appVeyor, bool teamCity, bool myGet, bool bamboo, bool continuaCI, bool jenkins, bool bitrise, bool travisCI, bool bitbucketPipelines, bool goCD, bool gitLabCI, bool tfs, bool vsts, bool azurePipelines, bool azurePipelinesHosted, bool gitHubActions, bool isPullRequest) + [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false)] // none + [InlineData(true, false, false, false, false, false, false, false, false, false, false, false, false, false, true)] // appveyor + [InlineData(false, true, false, false, false, false, false, false, false, false, false, false, false, false, true)] // teamcity + [InlineData(false, false, true, false, false, false, false, false, false, false, false, false, false, false, false)] // myget + [InlineData(false, false, false, true, false, false, false, false, false, false, false, false, false, false, false)] // bamboo + [InlineData(false, false, false, false, true, false, false, false, false, false, false, false, false, false, false)] // continua + [InlineData(false, false, false, false, false, true, false, false, false, false, false, false, false, false, true)] // jenkins + [InlineData(false, false, false, false, false, false, true, false, false, false, false, false, false, false, true)] // bitrise + [InlineData(false, false, false, false, false, false, false, true, false, false, false, false, false, false, true)] // travis + [InlineData(false, false, false, false, false, false, false, false, true, false, false, false, false, false, true)] // bitbucket + [InlineData(false, false, false, false, false, false, false, false, false, true, false, false, false, false, false)] // gocd + [InlineData(false, false, false, false, false, false, false, false, false, false, true, false, false, false, true)] // gitlab + [InlineData(false, false, false, false, false, false, false, false, false, false, false, true, false, false, true)] // az pipelines + [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, true, false, true)] // az pipelines hosted + [InlineData(false, false, false, false, false, false, false, false, false, false, false, false, false, true, true)] // gh actions + public void Should_Return_True_If_Running_On_Supported_Provider(bool appVeyor, bool teamCity, bool myGet, bool bamboo, bool continuaCI, bool jenkins, bool bitrise, bool travisCI, bool bitbucketPipelines, bool goCD, bool gitLabCI, bool azurePipelines, bool azurePipelinesHosted, bool gitHubActions, bool isPullRequest) { // Given var appVeyorProvider = Substitute.For(); @@ -1149,10 +1065,6 @@ public void Should_Return_True_If_Running_On_Supported_Provider(bool appVeyor, b goCDProvider.IsRunningOnGoCD.Returns(goCD); gitLabCIProvider.IsRunningOnGitLabCI.Returns(gitLabCI); gitLabCIProvider.Environment.Returns(gitLabCIEnvironment); -#pragma warning disable 618 - tfBuildProvider.IsRunningOnTFS.Returns(tfs); - tfBuildProvider.IsRunningOnVSTS.Returns(vsts); -#pragma warning restore 618 tfBuildProvider.IsRunningOnAzurePipelines.Returns(azurePipelines); tfBuildProvider.IsRunningOnAzurePipelinesHosted.Returns(azurePipelinesHosted); tfBuildProvider.Environment.Returns(tfBuildEnvironment); diff --git a/src/Cake.Common.Tests/Unit/Build/TFBuild/Data/TFBuildRepositoryInfoTests.cs b/src/Cake.Common.Tests/Unit/Build/TFBuild/Data/TFBuildRepositoryInfoTests.cs index ef6783bbf7..57d7f74a8f 100644 --- a/src/Cake.Common.Tests/Unit/Build/TFBuild/Data/TFBuildRepositoryInfoTests.cs +++ b/src/Cake.Common.Tests/Unit/Build/TFBuild/Data/TFBuildRepositoryInfoTests.cs @@ -10,24 +10,6 @@ namespace Cake.Common.Tests.Unit.Build.TFBuild.Data { public sealed class TFBuildRepositoryInfoTests { - public sealed class TheBranchProperty - { - [Fact] - public void Should_Return_Correct_Value() - { - // Given - var info = new TFBuildInfoFixture().CreateRepositoryInfo(); - - // When -#pragma warning disable 618 - var result = info.Branch; -#pragma warning restore 618 - - // Then - Assert.Equal("develop", result); - } - } - public sealed class TheSourceBranchNameProperty { [Fact] diff --git a/src/Cake.Common.Tests/Unit/Build/TFBuild/TFBuildProviderTests.cs b/src/Cake.Common.Tests/Unit/Build/TFBuild/TFBuildProviderTests.cs index 6f1980ca4f..c51a1757d3 100644 --- a/src/Cake.Common.Tests/Unit/Build/TFBuild/TFBuildProviderTests.cs +++ b/src/Cake.Common.Tests/Unit/Build/TFBuild/TFBuildProviderTests.cs @@ -37,78 +37,6 @@ public void Should_Throw_If_Writer_Is_Null() } } - public sealed class TheIsRunningOnTFSProperty - { - [Fact] - public void Should_Return_True_If_Running_On_TFS() - { - // Given - var fixture = new TFBuildFixture(); - fixture.IsRunningOnTFS(); - var tfBuild = fixture.CreateTFBuildService(); - - // When -#pragma warning disable 618 - var result = tfBuild.IsRunningOnTFS; -#pragma warning restore 618 - - // Then - Assert.True(result); - } - - [Fact] - public void Should_Return_False_If_Not_Running_On_TFS() - { - // Given - var fixture = new TFBuildFixture(); - var tfBuild = fixture.CreateTFBuildService(); - - // When -#pragma warning disable 618 - var result = tfBuild.IsRunningOnTFS; -#pragma warning restore 618 - - // Then - Assert.False(result); - } - } - - public sealed class TheIsRunningOnVSTSProperty - { - [Fact] - public void Should_Return_True_If_Running_On_VSTS() - { - // Given - var fixture = new TFBuildFixture(); - fixture.IsRunningOnVSTS(); - var tfBuild = fixture.CreateTFBuildService(); - - // When -#pragma warning disable 618 - var result = tfBuild.IsRunningOnVSTS; -#pragma warning restore 618 - - // Then - Assert.True(result); - } - - [Fact] - public void Should_Return_False_If_Not_Running_On_VSTS() - { - // Given - var fixture = new TFBuildFixture(); - var tfBuild = fixture.CreateTFBuildService(); - - // When -#pragma warning disable 618 - var result = tfBuild.IsRunningOnVSTS; -#pragma warning restore 618 - - // Then - Assert.False(result); - } - } - public sealed class TheIsRunningOnAzurePipelinesProperty { [Fact] diff --git a/src/Cake.Common.Tests/Unit/IO/DirectoryAliasesTests.cs b/src/Cake.Common.Tests/Unit/IO/DirectoryAliasesTests.cs index 75fc1ab2f5..ab09599f8b 100644 --- a/src/Cake.Common.Tests/Unit/IO/DirectoryAliasesTests.cs +++ b/src/Cake.Common.Tests/Unit/IO/DirectoryAliasesTests.cs @@ -600,106 +600,6 @@ public void Should_Make_Relative_Path_Absolute() public sealed class TheDeleteDirectoryMethod { - [Fact] - public void Should_Throw_If_Context_Is_Null() - { - // Given, When -#pragma warning disable CS0618 - var result = Record.Exception(() => DirectoryAliases.DeleteDirectory(null, "/Temp/DoNotExist")); -#pragma warning restore CS0618 - - // Then - AssertEx.IsArgumentNullException(result, "context"); - } - - [Fact] - public void Should_Throw_If_Directory_Is_Null() - { - // Given - var fixture = new FileSystemFixture(); - var context = Substitute.For(); - context.FileSystem.Returns(fixture.FileSystem); - - // When -#pragma warning disable CS0618 - var result = Record.Exception(() => context.DeleteDirectory(null)); -#pragma warning restore CS0618 - - // Then - AssertEx.IsArgumentNullException(result, "path"); - } - - [Fact] - public void Should_Throw_If_Directory_Do_Not_Exist() - { - // Given - var fixture = new FileSystemFixture(); - var context = Substitute.For(); - context.FileSystem.Returns(fixture.FileSystem); - - // When -#pragma warning disable CS0618 - var result = Record.Exception(() => context.DeleteDirectory("/Temp/DoNotExist")); -#pragma warning restore CS0618 - - // Then - Assert.IsType(result); - Assert.Equal("The directory '/Temp/DoNotExist' does not exist.", result?.Message); - } - - [Fact] - public void Should_Throw_When_Deleting_Directory_With_Sub_Directories_If_Non_Recursive() - { - // Given - var fixture = new FileSystemFixture(); - var context = Substitute.For(); - context.FileSystem.Returns(fixture.FileSystem); - - // When -#pragma warning disable CS0618 - var result = Record.Exception(() => context.DeleteDirectory("/Temp/HasDirectories")); -#pragma warning restore CS0618 - - // Then - Assert.IsType(result); - Assert.Equal("Cannot delete directory '/Temp/HasDirectories' without recursion since it's not empty.", result?.Message); - } - - [Fact] - public void Should_Throw_When_Deleting_Directory_With_Files_If_Non_Recursive() - { - // Given - var fixture = new FileSystemFixture(); - var context = Substitute.For(); - context.FileSystem.Returns(fixture.FileSystem); - - // When -#pragma warning disable CS0618 - var result = Record.Exception(() => context.DeleteDirectory("/Temp/HasFiles")); -#pragma warning restore CS0618 - - // Then - Assert.IsType(result); - Assert.Equal("Cannot delete directory '/Temp/HasFiles' without recursion since it's not empty.", result?.Message); - } - - [Fact] - public void Should_Delete_Empty_Directory_If_Non_Recursive() - { - // Given - var fixture = new FileSystemFixture(); - var context = Substitute.For(); - context.FileSystem.Returns(fixture.FileSystem); - - // When -#pragma warning disable CS0618 - context.DeleteDirectory("/Temp/Hello/Empty"); -#pragma warning restore CS0618 - - // Then - Assert.False(fixture.FileSystem.GetDirectory("/Temp/Hello/Empty").Exists); - } - [Fact] public void Should_Delete_Directory_With_Content_If_Recursive() { @@ -751,120 +651,6 @@ public sealed class TheDeleteDirectoriesMethod { public sealed class WithPaths { - [Fact] - public void Should_Throw_If_Context_Is_Null() - { - // Given - var paths = new DirectoryPath[] { "/Temp/DoNotExist" }; - - // When - var result = Record.Exception(() => -#pragma warning disable CS0618 - DirectoryAliases.DeleteDirectories(null, paths)); -#pragma warning restore CS0618 - - // Then - AssertEx.IsArgumentNullException(result, "context"); - } - - [Fact] - public void Should_Throw_If_Directories_Are_Null() - { - // Given - var context = Substitute.For(); - - // When - var result = Record.Exception(() => -#pragma warning disable CS0618 - context.DeleteDirectories((IEnumerable)null)); -#pragma warning restore CS0618 - - // Then - AssertEx.IsArgumentNullException(result, "directories"); - } - - [Fact] - public void Should_Throw_If_Any_Directory_Do_Not_Exist() - { - // Given - var fixture = new FileSystemFixture(); - var context = Substitute.For(); - context.FileSystem.Returns(fixture.FileSystem); - - var paths = new DirectoryPath[] { "/Temp/DoNotExist" }; - - // When -#pragma warning disable CS0618 - var result = Record.Exception(() => context.DeleteDirectories(paths)); -#pragma warning restore CS0618 - - // Then - Assert.IsType(result); - Assert.Equal("The directory '/Temp/DoNotExist' does not exist.", result?.Message); - } - - [Fact] - public void Should_Throw_When_Deleting_Directory_With_Sub_Directories_If_Non_Recursive() - { - // Given - var fixture = new FileSystemFixture(); - var context = Substitute.For(); - context.FileSystem.Returns(fixture.FileSystem); - - var paths = new DirectoryPath[] { "/Temp/HasDirectories" }; - - // When - var result = Record.Exception(() => -#pragma warning disable CS0618 - context.DeleteDirectories(paths)); -#pragma warning restore CS0618 - - // Then - Assert.IsType(result); - Assert.Equal("Cannot delete directory '/Temp/HasDirectories' without recursion since it's not empty.", result?.Message); - } - - [Fact] - public void Should_Throw_When_Deleting_Directory_With_Files_If_Non_Recursive() - { - // Given - var fixture = new FileSystemFixture(); - var context = Substitute.For(); - context.FileSystem.Returns(fixture.FileSystem); - - var paths = new DirectoryPath[] { "/Temp/HasFiles" }; - - // When - var result = Record.Exception(() => -#pragma warning disable CS0618 - context.DeleteDirectories(paths)); -#pragma warning restore CS0618 - - // Then - Assert.IsType(result); - Assert.Equal("Cannot delete directory '/Temp/HasFiles' without recursion since it's not empty.", result?.Message); - } - - [Fact] - public void Should_Delete_Empty_Directory_If_Non_Recursive() - { - // Given - var fixture = new FileSystemFixture(); - var context = Substitute.For(); - context.FileSystem.Returns(fixture.FileSystem); - - var paths = new DirectoryPath[] { "/Temp/Hello/Empty", "/Temp/Hello/More/Empty" }; - - // When -#pragma warning disable CS0618 - context.DeleteDirectories(paths); -#pragma warning restore CS0618 - - // Then - Assert.False(fixture.FileSystem.GetDirectory("/Temp/Hello/Empty").Exists); - Assert.False(fixture.FileSystem.GetDirectory("/Temp/Hello/More/Empty").Exists); - } - [Fact] public void Should_Delete_Directory_With_Content_If_Recursive() { @@ -921,121 +707,6 @@ public void Should_Delete_Directories_With_Readonly_Files_If_Force() public sealed class WithStrings { - [Fact] - public void Should_Throw_If_Context_Is_Null() - { - // Given - var paths = new[] { "/Temp/DoNotExist" }; - - // When - var result = Record.Exception(() => -#pragma warning disable CS0618 - DirectoryAliases.DeleteDirectories(null, paths)); -#pragma warning restore CS0618 - - // Then - AssertEx.IsArgumentNullException(result, "context"); - } - - [Fact] - public void Should_Throw_If_Directories_Are_Null() - { - // Given - var context = Substitute.For(); - - // When - var result = Record.Exception(() => -#pragma warning disable CS0618 - context.DeleteDirectories((IEnumerable)null)); -#pragma warning restore CS0618 - - // Then - AssertEx.IsArgumentNullException(result, "directories"); - } - - [Fact] - public void Should_Throw_If_Any_Directory_Do_Not_Exist() - { - // Given - var fixture = new FileSystemFixture(); - var context = Substitute.For(); - context.FileSystem.Returns(fixture.FileSystem); - - var paths = new[] { "/Temp/DoNotExist" }; - - // When - var result = Record.Exception(() => -#pragma warning disable CS0618 - context.DeleteDirectories(paths)); -#pragma warning restore CS0618 - - // Then - Assert.IsType(result); - Assert.Equal("The directory '/Temp/DoNotExist' does not exist.", result?.Message); - } - - [Fact] - public void Should_Throw_When_Deleting_Directory_With_Sub_Directories_If_Non_Recursive() - { - // Given - var fixture = new FileSystemFixture(); - var context = Substitute.For(); - context.FileSystem.Returns(fixture.FileSystem); - - var paths = new[] { "/Temp/HasDirectories" }; - - // When - var result = Record.Exception(() => -#pragma warning disable CS0618 - context.DeleteDirectories(paths)); -#pragma warning restore CS0618 - - // Then - Assert.IsType(result); - Assert.Equal("Cannot delete directory '/Temp/HasDirectories' without recursion since it's not empty.", result?.Message); - } - - [Fact] - public void Should_Throw_When_Deleting_Directory_With_Files_If_Non_Recursive() - { - // Given - var fixture = new FileSystemFixture(); - var context = Substitute.For(); - context.FileSystem.Returns(fixture.FileSystem); - - var paths = new[] { "/Temp/HasFiles" }; - - // When - var result = Record.Exception(() => -#pragma warning disable CS0618 - context.DeleteDirectories(paths)); -#pragma warning restore CS0618 - - // Then - Assert.IsType(result); - Assert.Equal("Cannot delete directory '/Temp/HasFiles' without recursion since it's not empty.", result?.Message); - } - - [Fact] - public void Should_Delete_Empty_Directory_If_Non_Recursive() - { - // Given - var fixture = new FileSystemFixture(); - var context = Substitute.For(); - context.FileSystem.Returns(fixture.FileSystem); - - var paths = new[] { "/Temp/Hello/Empty", "/Temp/Hello/More/Empty" }; - - // When -#pragma warning disable CS0618 - context.DeleteDirectories(paths); -#pragma warning restore CS0618 - - // Then - Assert.False(fixture.FileSystem.GetDirectory("/Temp/Hello/Empty").Exists); - Assert.False(fixture.FileSystem.GetDirectory("/Temp/Hello/More/Empty").Exists); - } - [Fact] public void Should_Delete_Directory_With_Content_If_Recursive() { diff --git a/src/Cake.Common.Tests/Unit/Tools/DotNetBuildSettingsExtensionsTests.cs b/src/Cake.Common.Tests/Unit/Tools/DotNetBuildSettingsExtensionsTests.cs deleted file mode 100644 index 6a4aa4976f..0000000000 --- a/src/Cake.Common.Tests/Unit/Tools/DotNetBuildSettingsExtensionsTests.cs +++ /dev/null @@ -1,135 +0,0 @@ -// 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 Cake.Common.Tools; -using Cake.Core.Diagnostics; -using Cake.Core.IO; -using Xunit; - -namespace Cake.Common.Tests.Unit.Tools -{ - public sealed class DotNetBuildSettingsExtensionsTests - { - public sealed class TheWithTargetMethod - { - [Fact] - public void Should_Add_Target_To_Configuration() - { - // Given - var settings = new DotNetBuildSettings(new FilePath("./Test.sln")); - - // When - settings.WithTarget("Target"); - - // Then - Assert.True(settings.Targets.Contains("Target")); - } - - [Fact] - public void Should_Return_The_Same_Configuration() - { - // Given - var settings = new DotNetBuildSettings(new FilePath("./Test.sln")); - - // When - var result = settings.WithTarget("Target"); - - // Then - Assert.Equal(settings, result); - } - } - - public sealed class TheWithPropertyMethod - { - [Fact] - public void Should_Add_Property_To_Configuration() - { - // Given - var settings = new DotNetBuildSettings(new FilePath("./Test.sln")); - - // When - settings.WithProperty("PropertyName", "Value"); - - // Then - Assert.True(settings.Properties.ContainsKey("PropertyName")); - } - - [Fact] - public void Should_Return_The_Same_Configuration() - { - // Given - var settings = new DotNetBuildSettings(new FilePath("./Test.sln")); - - // When - var result = settings.WithProperty("PropertyName", "Value"); - - // Then - Assert.Equal(settings, result); - } - } - - public sealed class TheSetConfigurationMethod - { - [Fact] - public void Should_Set_Configuration() - { - // Given - var settings = new DotNetBuildSettings(new FilePath("./Test.sln")); - - // When - settings.SetConfiguration("TheConfiguration"); - - // Then - Assert.Equal("TheConfiguration", settings.Configuration); - } - - [Fact] - public void Should_Return_The_Same_Configuration() - { - // Given - var settings = new DotNetBuildSettings(new FilePath("./Test.sln")); - - // When - var result = settings.SetConfiguration("TheConfiguration"); - - // Then - Assert.Equal(settings, result); - } - } - - public sealed class TheSetVerbosityMethod - { - [Theory] - [InlineData(Verbosity.Quiet)] - [InlineData(Verbosity.Minimal)] - [InlineData(Verbosity.Normal)] - [InlineData(Verbosity.Verbose)] - [InlineData(Verbosity.Diagnostic)] - public void Should_Set_Verbosity(Verbosity verbosity) - { - // Given - var settings = new DotNetBuildSettings(new FilePath("./Test.sln")); - - // When - settings.SetVerbosity(verbosity); - - // Then - Assert.Equal(verbosity, settings.Verbosity); - } - - [Fact] - public void Should_Return_The_Same_Configuration() - { - // Given - var settings = new DotNetBuildSettings(new FilePath("./Test.sln")); - - // When - var result = settings.SetVerbosity(Verbosity.Normal); - - // Then - Assert.Equal(settings, result); - } - } - } -} \ No newline at end of file diff --git a/src/Cake.Common.Tests/Unit/Tools/DotNetBuildSettingsTests.cs b/src/Cake.Common.Tests/Unit/Tools/DotNetBuildSettingsTests.cs deleted file mode 100644 index d5bb5c7076..0000000000 --- a/src/Cake.Common.Tests/Unit/Tools/DotNetBuildSettingsTests.cs +++ /dev/null @@ -1,98 +0,0 @@ -// 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 Cake.Common.Tools; -using Cake.Core.Diagnostics; -using Cake.Core.IO; -using Xunit; - -namespace Cake.Common.Tests.Unit.Tools -{ - public sealed class DotNetBuildSettingsTests - { - public sealed class TheConstructor - { - [Fact] - public void Should_Set_Default_Verbosity_To_Normal() - { - // Given, When - var settings = new DotNetBuildSettings(new FilePath("./Test.sln")); - - // Then - Assert.Equal(Verbosity.Normal, settings.Verbosity); - } - - [Fact] - public void Should_Throw_If_Solution_Is_Null() - { - // Given, When - var result = Record.Exception(() => new DotNetBuildSettings(null)); - - // Then - AssertEx.IsArgumentNullException(result, "solution"); - } - } - - public sealed class TheTargetsProperty - { - [Fact] - public void Should_Return_A_Set_That_Is_Case_Insensitive() - { - // Given - var settings = new DotNetBuildSettings(new FilePath("./Test.sln")); - - // When - settings.Targets.Add("TARGET"); - - // Then - Assert.True(settings.Targets.Contains("target")); - } - } - - public sealed class ThePropertiesProperty - { - [Fact] - public void Should_Return_A_Dictionary_That_Is_Case_Insensitive() - { - // Given - var settings = new DotNetBuildSettings(new FilePath("./Test.sln")); - - // When - settings.Properties.Add("THEKEY", new[] { "THEVALUE" }); - - // Then - Assert.True(settings.Properties.ContainsKey("thekey")); - } - } - - public sealed class TheConfigurationProperty - { - [Fact] - public void Should_Be_Empty_By_Default() - { - // Given, When - var settings = new DotNetBuildSettings(new FilePath("./Test.sln")); - - // Then - Assert.Equal(string.Empty, settings.Configuration); - } - } - - public sealed class TheSolutionProperty - { - [Fact] - public void Should_Return_Passed_Constructor_Argument() - { - // Given - var solution = new FilePath("./Test.sln"); - - // When - var settings = new DotNetBuildSettings(solution); - - // Then - Assert.Equal(solution, settings.Solution); - } - } - } -} \ No newline at end of file diff --git a/src/Cake.Common.Tests/Unit/Tools/NUnit/NUnit3RunnerTests.cs b/src/Cake.Common.Tests/Unit/Tools/NUnit/NUnit3RunnerTests.cs index 98a36b0290..e427e8218a 100644 --- a/src/Cake.Common.Tests/Unit/Tools/NUnit/NUnit3RunnerTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/NUnit/NUnit3RunnerTests.cs @@ -219,10 +219,6 @@ public void Should_Set_Commandline_Switches() fixture.Settings.SkipNonTestAssemblies = true; fixture.Settings.Work = "out"; fixture.Settings.OutputFile = "stdout.txt"; - #pragma warning disable 0618 - fixture.Settings.ErrorOutputFile = "stderr.txt"; - fixture.Settings.Full = true; - #pragma warning restore 0618 fixture.Settings.Results = new[] { new NUnit3Result { FileName = "NewTestResult.xml", Format = "nunit2", Transform = "nunit2.xslt" }, @@ -232,9 +228,6 @@ public void Should_Set_Commandline_Switches() fixture.Settings.TeamCity = true; fixture.Settings.NoHeader = true; fixture.Settings.NoColor = true; - #pragma warning disable 0618 - fixture.Settings.Verbose = true; - #pragma warning restore 0618 fixture.Settings.Configuration = "Debug"; fixture.Settings.Process = NUnit3ProcessOption.InProcess; fixture.Settings.AppDomainUsage = NUnit3AppDomainUsage.Single; @@ -259,10 +252,9 @@ public void Should_Set_Commandline_Switches() Assert.Equal("\"/Working/Test1.dll\" --test=Test1,Test2 \"--testlist=/Working/Testlist.txt\" " + "--where \"cat==Data\" --timeout=5 --seed=6 --workers=7 " + "--stoponerror --skipnontestassemblies \"--work=/Working/out\" \"--out=/Working/stdout.txt\" " + - "\"--err=/Working/stderr.txt\" --full " + "\"--result=/Working/NewTestResult.xml;format=nunit2;transform=/Working/nunit2.xslt\" " + "\"--result=/Working/NewTestResult2.xml;format=nunit3\" " + - "--labels=All --teamcity --noheader --nocolor --verbose " + + "--labels=All --teamcity --noheader --nocolor " + "\"--config=Debug\" \"--framework=net3.5\" --x86 " + "--dispose-runners --shadowcopy --agents=3 " + "--process=InProcess --domain=Single " + diff --git a/src/Cake.Common/Build/BuildSystem.cs b/src/Cake.Common/Build/BuildSystem.cs index 145a94659d..6bbefb34d6 100644 --- a/src/Cake.Common/Build/BuildSystem.cs +++ b/src/Cake.Common/Build/BuildSystem.cs @@ -127,9 +127,6 @@ public BuildSystem( BitbucketPipelines = bitbucketPipelinesProvider; GoCD = goCDProvider; GitLabCI = gitLabCIProvider; -#pragma warning disable CS0618 // Type or member is obsolete - TFBuild = tfBuildProvider; -#pragma warning restore CS0618 // Type or member is obsolete GitHubActions = gitHubActionsProvider; AzurePipelines = azurePipelinesProvider; @@ -508,42 +505,6 @@ public BuildSystem( /// public bool IsRunningOnGitLabCI => GitLabCI.IsRunningOnGitLabCI; - /// - /// Gets a value indicating whether this instance is running on TFS. - /// - /// - /// - /// if (BuildSystem.IsRunningOnTFS) - /// { - /// // Get the build commit hash. - /// var commitHash = BuildSystem.TFBuild.Environment.Repository.SourceVersion; - /// } - /// - /// - /// - /// true if this instance is running on TFS; otherwise, false. - /// - [Obsolete("Please use BuildSystem.IsRunningOnAzurePipelines instead.")] - public bool IsRunningOnTFS => TFBuild.IsRunningOnTFS; - - /// - /// Gets a value indicating whether this instance is running on VSTS. - /// - /// - /// - /// if (BuildSystem.IsRunningOnVSTS) - /// { - /// // Get the build commit hash. - /// var commitHash = BuildSystem.TFBuild.Environment.Repository.SourceVersion; - /// } - /// - /// - /// - /// true if this instance is running on VSTS; otherwise, false. - /// - [Obsolete("Please use BuildSystem.IsRunningOnAzurePipelinesHosted instead.")] - public bool IsRunningOnVSTS => TFBuild.IsRunningOnVSTS; - /// /// Gets a value indicating whether this instance is running on Azure Pipelines. /// @@ -578,21 +539,6 @@ public BuildSystem( /// public bool IsRunningOnAzurePipelinesHosted => AzurePipelines.IsRunningOnAzurePipelinesHosted; - /// - /// Gets the TF Build Provider. - /// - /// - /// - /// if (BuildSystem.IsRunningOnVSTS) - /// { - /// // Get the build definition name. - /// var definitionName = BuildSystem.TFBuild.Environment.BuildDefinition.Name; - /// } - /// - /// - [Obsolete("Please use BuildSystem.AzurePipelines instead.")] - public ITFBuildProvider TFBuild { get; } - /// /// Gets the Azure Pipelines Provider. /// diff --git a/src/Cake.Common/Build/BuildSystemAliases.cs b/src/Cake.Common/Build/BuildSystemAliases.cs index 4bfd966846..e95ec7abd3 100644 --- a/src/Cake.Common/Build/BuildSystemAliases.cs +++ b/src/Cake.Common/Build/BuildSystemAliases.cs @@ -338,32 +338,6 @@ public static IGitLabCIProvider GitLabCI(this ICakeContext context) return buildSystem.GitLabCI; } - /// - /// Gets a instance that can be used to - /// obtain information from the Team Foundation Build environment. - /// - /// - /// - /// var isTFSBuild = TFBuild.IsRunningOnTFS; - /// - /// - /// The context. - /// A instance. - [CakePropertyAlias(Cache = true)] - [CakeNamespaceImport("Cake.Common.Build.TFBuild")] - [CakeNamespaceImport("Cake.Common.Build.TFBuild.Data")] - [Obsolete("Use AzurePipelines instead.")] - public static ITFBuildProvider TFBuild(this ICakeContext context) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - var buildSystem = context.BuildSystem(); - return buildSystem.TFBuild; - } - /// /// Gets a instance that can be used to /// obtain information from the GitHub Actions environment. diff --git a/src/Cake.Common/Build/TFBuild/Data/TFBuildRepositoryInfo.cs b/src/Cake.Common/Build/TFBuild/Data/TFBuildRepositoryInfo.cs index fcdb88291a..88368d3491 100644 --- a/src/Cake.Common/Build/TFBuild/Data/TFBuildRepositoryInfo.cs +++ b/src/Cake.Common/Build/TFBuild/Data/TFBuildRepositoryInfo.cs @@ -37,15 +37,6 @@ public TFBuildRepositoryInfo(ICakeEnvironment environment) /// public string SourceBranchName => GetEnvironmentString("BUILD_SOURCEBRANCHNAME"); - /// - /// Gets name of the branch the build was queued for. - /// - /// - /// The SCM branch name. - /// - [Obsolete("Please use TFBuildRepositoryInfo.SourceBranchName instead")] - public string Branch => SourceBranchName; - /// /// Gets the latest version control change that is included in this build. /// diff --git a/src/Cake.Common/Build/TFBuild/ITFBuildProvider.cs b/src/Cake.Common/Build/TFBuild/ITFBuildProvider.cs index b867d93d44..50586e577c 100644 --- a/src/Cake.Common/Build/TFBuild/ITFBuildProvider.cs +++ b/src/Cake.Common/Build/TFBuild/ITFBuildProvider.cs @@ -12,24 +12,6 @@ namespace Cake.Common.Build.TFBuild /// public interface ITFBuildProvider { - /// - /// Gets a value indicating whether the current build is running on TFS. - /// - /// - /// true if the current build is running on TFS; otherwise, false. - /// - [Obsolete("Please use ITFBuildProvider.IsRunningOnAzurePipelines instead.")] - bool IsRunningOnTFS { get; } - - /// - /// Gets a value indicating whether the current build is running on VSTS. - /// - /// - /// true if the current build is running on VSTS; otherwise, false. - /// - [Obsolete("Please use ITFBuildProvider.IsRunningOnAzurePipelinesHosted instead.")] - bool IsRunningOnVSTS { get; } - /// /// Gets a value indicating whether the current build is running on Azure Pipelines. /// diff --git a/src/Cake.Common/Build/TFBuild/TFBuildProvider.cs b/src/Cake.Common/Build/TFBuild/TFBuildProvider.cs index 727fc24d66..f4ba1ec16e 100644 --- a/src/Cake.Common/Build/TFBuild/TFBuildProvider.cs +++ b/src/Cake.Common/Build/TFBuild/TFBuildProvider.cs @@ -27,24 +27,6 @@ public TFBuildProvider(ICakeEnvironment environment, IBuildSystemServiceMessageW Commands = new TFBuildCommands(environment, writer); } - /// - /// Gets a value indicating whether the current build is running on TFS. - /// - /// - /// true if the current build is running on TFS; otherwise, false. - /// - [Obsolete("Please use TFBuildProvider.IsRunningOnAzurePipelines instead.")] - public bool IsRunningOnTFS => IsRunningOnAzurePipelines; - - /// - /// Gets a value indicating whether the current build is running on VSTS. - /// - /// - /// true if the current build is running on VSTS; otherwise, false. - /// - [Obsolete("Please use TFBuildProvider.IsRunningOnAzurePipelinesHosted instead.")] - public bool IsRunningOnVSTS => IsRunningOnAzurePipelinesHosted; - /// /// Gets a value indicating whether the current build is running on Azure Pipelines. /// diff --git a/src/Cake.Common/IO/DirectoryAliases.cs b/src/Cake.Common/IO/DirectoryAliases.cs index 49f4a2b292..53305bb22e 100644 --- a/src/Cake.Common/IO/DirectoryAliases.cs +++ b/src/Cake.Common/IO/DirectoryAliases.cs @@ -50,34 +50,6 @@ public static ConvertableDirectoryPath Directory(this ICakeContext context, stri return new ConvertableDirectoryPath(new DirectoryPath(path)); } - /// - /// Deletes the specified directories. - /// - /// - /// - /// var directoriesToDelete = new DirectoryPath[]{ - /// Directory("be"), - /// Directory("gone") - /// }; - /// DeleteDirectories(directoriesToDelete, recursive:true); - /// - /// - /// The context. - /// The directory paths. - /// Will perform a recursive delete if set to true. - [Obsolete("Use the overload that accepts DeleteDirectorySettings instead.")] - [CakeMethodAlias] - [CakeAliasCategory("Delete")] - public static void DeleteDirectories(this ICakeContext context, IEnumerable directories, bool recursive = false) - { - if (directories == null) - { - throw new ArgumentNullException(nameof(directories)); - } - - DeleteDirectories(context, directories, new DeleteDirectorySettings { Recursive = recursive }); - } - /// /// Deletes the specified directories. /// @@ -111,29 +83,6 @@ public static void DeleteDirectories(this ICakeContext context, IEnumerable - /// Deletes the specified directories. - /// - /// - /// - /// var directoriesToDelete = new []{ - /// "be", - /// "gone" - /// }; - /// DeleteDirectories(directoriesToDelete, recursive:true); - /// - /// - /// The context. - /// The directory paths. - /// Will perform a recursive delete if set to true. - [Obsolete("Use the overload that accepts DeleteDirectorySettings instead.")] - [CakeMethodAlias] - [CakeAliasCategory("Delete")] - public static void DeleteDirectories(this ICakeContext context, IEnumerable directories, bool recursive = false) - { - DeleteDirectories(context, directories, new DeleteDirectorySettings { Recursive = recursive }); - } - /// /// Deletes the specified directories. /// @@ -168,25 +117,6 @@ public static void DeleteDirectories(this ICakeContext context, IEnumerable - /// Deletes the specified directory. - /// - /// - /// - /// DeleteDirectory("./be/gone", recursive:true); - /// - /// - /// The context. - /// The directory path. - /// Will perform a recursive delete if set to true. - [Obsolete("Use the overload that accepts DeleteDirectorySettings instead.")] - [CakeMethodAlias] - [CakeAliasCategory("Delete")] - public static void DeleteDirectory(this ICakeContext context, DirectoryPath path, bool recursive = false) - { - DeleteDirectory(context, path, new DeleteDirectorySettings { Recursive = recursive }); - } - /// /// Deletes the specified directory. /// diff --git a/src/Cake.Common/IO/GlobbingAliases.cs b/src/Cake.Common/IO/GlobbingAliases.cs index ff52cfd3b6..d43ed5d9d2 100644 --- a/src/Cake.Common/IO/GlobbingAliases.cs +++ b/src/Cake.Common/IO/GlobbingAliases.cs @@ -43,39 +43,6 @@ public static FilePathCollection GetFiles(this ICakeContext context, string patt return new FilePathCollection(context.Globber.Match(pattern).OfType()); } - /// - /// Gets all files matching the specified pattern. - /// - /// - /// - /// Func<IFileSystemInfo, bool> exclude_node_modules = - /// fileSystemInfo => !fileSystemInfo.Path.FullPath.EndsWith( - /// "node_modules", StringComparison.OrdinalIgnoreCase); - /// - /// var files = GetFiles("./**/Cake.*.dll", exclude_node_modules); - /// foreach(var file in files) - /// { - /// Information("File: {0}", file); - /// } - /// - /// - /// The context. - /// The glob pattern to match. - /// The predicate used to filter directories based on file system information. - /// A . - [CakeMethodAlias] - [CakeAliasCategory("Files")] - [Obsolete("Please use the GetFiles overload that accept globber settings instead.", false)] - public static FilePathCollection GetFiles(this ICakeContext context, string pattern, Func predicate) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - return new FilePathCollection(context.Globber.Match(pattern, predicate).OfType()); - } - /// /// Gets all files matching the specified pattern. /// @@ -135,39 +102,6 @@ public static DirectoryPathCollection GetDirectories(this ICakeContext context, return new DirectoryPathCollection(context.Globber.Match(pattern).OfType()); } - /// - /// Gets all directories matching the specified pattern. - /// - /// - /// - /// Func<IFileSystemInfo, bool> exclude_node_modules = - /// fileSystemInfo => !fileSystemInfo.Path.FullPath.EndsWith( - /// "node_modules", StringComparison.OrdinalIgnoreCase); - /// - /// var directories = GetDirectories("./src/**/obj/*", exclude_node_modules); - /// foreach(var directory in directories) - /// { - /// Information("Directory: {0}", directory); - /// } - /// - /// - /// The context. - /// The glob pattern to match. - /// The predicate used to filter directories based on file system information. - /// A . - [CakeMethodAlias] - [CakeAliasCategory("Directories")] - [Obsolete("Please use the GetDirectories overload that accept globber settings instead.", false)] - public static DirectoryPathCollection GetDirectories(this ICakeContext context, string pattern, Func predicate) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - return new DirectoryPathCollection(context.Globber.Match(pattern, predicate).OfType()); - } - /// /// Gets all directories matching the specified pattern. /// diff --git a/src/Cake.Common/Tools/DotNetBuildAliases.cs b/src/Cake.Common/Tools/DotNetBuildAliases.cs deleted file mode 100644 index 76a3947aa4..0000000000 --- a/src/Cake.Common/Tools/DotNetBuildAliases.cs +++ /dev/null @@ -1,110 +0,0 @@ -// 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; -using Cake.Common.Tools.MSBuild; -using Cake.Common.Tools.XBuild; -using Cake.Core; -using Cake.Core.Annotations; -using Cake.Core.IO; - -namespace Cake.Common.Tools -{ - /// - /// Contains functionality to run either MSBuild on Windows or XBuild on Mac/Linux/Unix. - /// - [CakeAliasCategory("DotNetBuild")] - public static class DotNetBuildAliases - { - /// - /// Builds the specified solution using MSBuild or XBuild. - /// - /// - /// - /// DotNetBuild("./project/project.sln"); - /// - /// - /// The context. - /// The solution. - [CakeMethodAlias] - [Obsolete("Use MSBuild or XBuild instead.")] - public static void DotNetBuild(this ICakeContext context, FilePath solution) - { - DotNetBuild(context, solution, settings => { }); - } - - /// - /// Builds the specified solution using MSBuild or XBuild. - /// - /// - /// - /// DotNetBuild("./project/project.sln", settings => - /// settings.SetConfiguration("Debug") - /// .SetVerbosity(Core.Diagnostics.Verbosity.Minimal) - /// .WithTarget("Build") - /// .WithProperty("TreatWarningsAsErrors","true")); - /// - /// - /// The context. - /// The solution. - /// The configurator. - [CakeMethodAlias] - [Obsolete("Use MSBuild or XBuild instead.")] - public static void DotNetBuild(this ICakeContext context, FilePath solution, Action configurator) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - if (configurator == null) - { - throw new ArgumentNullException(nameof(configurator)); - } - - // Create the settings using the delegate. - var dotNetSettings = new DotNetBuildSettings(solution); - configurator(dotNetSettings); - - // Running on Mac/Linux/Unix? - if (context.Environment.Platform.IsUnix()) - { - // Use XBuild. - XBuildAliases.XBuild(context, solution, settings => - { - settings.Configuration = dotNetSettings.Configuration; - settings.Verbosity = dotNetSettings.Verbosity; - - foreach (var target in dotNetSettings.Targets) - { - settings.Targets.Add(target); - } - - foreach (var property in dotNetSettings.Properties) - { - settings.Properties.Add(property); - } - }); - } - else - { - // Use MSBuild. - MSBuildAliases.MSBuild(context, solution, settings => - { - settings.Configuration = dotNetSettings.Configuration; - settings.Verbosity = dotNetSettings.Verbosity; - - foreach (var target in dotNetSettings.Targets) - { - settings.Targets.Add(target); - } - - foreach (var property in dotNetSettings.Properties) - { - settings.Properties.Add(property); - } - }); - } - } - } -} \ No newline at end of file diff --git a/src/Cake.Common/Tools/DotNetBuildSettings.cs b/src/Cake.Common/Tools/DotNetBuildSettings.cs deleted file mode 100644 index da98ea3052..0000000000 --- a/src/Cake.Common/Tools/DotNetBuildSettings.cs +++ /dev/null @@ -1,70 +0,0 @@ -// 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; -using System.Collections.Generic; -using Cake.Core.Diagnostics; -using Cake.Core.IO; - -namespace Cake.Common.Tools -{ - /// - /// Contains settings used by the DotNetBuild alias. - /// - public sealed class DotNetBuildSettings - { - private readonly HashSet _targets; - private readonly Dictionary> _properties; - - /// - /// Gets the solution path. - /// - /// The solution. - public FilePath Solution { get; } - - /// - /// Gets the targets. - /// - /// The targets. - public ISet Targets => _targets; - - /// - /// Gets the properties. - /// - /// The properties. - public IDictionary> Properties => _properties; - - /// - /// Gets or sets the configuration. - /// - /// The configuration. - public string Configuration { get; set; } - - /// - /// Gets or sets the amount of information to display in the build log. - /// Each logger displays events based on the verbosity level that you set for that logger. - /// - /// The build log verbosity. - public Verbosity Verbosity { get; set; } - - /// - /// Initializes a new instance of the class. - /// - /// The solution. - public DotNetBuildSettings(FilePath solution) - { - if (solution == null) - { - throw new ArgumentNullException(nameof(solution)); - } - - Solution = solution; - _targets = new HashSet(StringComparer.OrdinalIgnoreCase); - _properties = new Dictionary>(StringComparer.OrdinalIgnoreCase); - - Configuration = string.Empty; - Verbosity = Verbosity.Normal; - } - } -} \ No newline at end of file diff --git a/src/Cake.Common/Tools/DotNetBuildSettingsExtensions.cs b/src/Cake.Common/Tools/DotNetBuildSettingsExtensions.cs deleted file mode 100644 index 550bed8dc3..0000000000 --- a/src/Cake.Common/Tools/DotNetBuildSettingsExtensions.cs +++ /dev/null @@ -1,90 +0,0 @@ -// 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; -using System.Collections.Generic; -using System.Linq; -using Cake.Core.Diagnostics; - -namespace Cake.Common.Tools -{ - /// - /// Contains functionality related to .NET build settings. - /// - public static class DotNetBuildSettingsExtensions - { - /// - /// Adds a .NET build target to the configuration. - /// - /// The settings. - /// The .NET build target. - /// The same instance so that multiple calls can be chained. - public static DotNetBuildSettings WithTarget(this DotNetBuildSettings settings, string target) - { - if (settings == null) - { - throw new ArgumentNullException(nameof(settings)); - } - settings.Targets.Add(target); - return settings; - } - - /// - /// Adds a property to the configuration. - /// - /// The settings. - /// The property name. - /// The property values. - /// The same instance so that multiple calls can be chained. - public static DotNetBuildSettings WithProperty(this DotNetBuildSettings settings, string name, params string[] values) - { - if (settings == null) - { - throw new ArgumentNullException(nameof(settings)); - } - - IList currentValue; - currentValue = new List( - settings.Properties.TryGetValue(name, out currentValue) && currentValue != null - ? currentValue.Concat(values) - : values); - - settings.Properties[name] = currentValue; - - return settings; - } - - /// - /// Sets the configuration. - /// - /// The settings. - /// The configuration. - /// The same instance so that multiple calls can be chained. - public static DotNetBuildSettings SetConfiguration(this DotNetBuildSettings settings, string configuration) - { - if (settings == null) - { - throw new ArgumentNullException(nameof(settings)); - } - settings.Configuration = configuration; - return settings; - } - - /// - /// Sets the build log verbosity. - /// - /// The settings. - /// The build log verbosity. - /// The same instance so that multiple calls can be chained. - public static DotNetBuildSettings SetVerbosity(this DotNetBuildSettings settings, Verbosity verbosity) - { - if (settings == null) - { - throw new ArgumentNullException(nameof(settings)); - } - settings.Verbosity = verbosity; - return settings; - } - } -} \ No newline at end of file diff --git a/src/Cake.Common/Tools/GitReleaseManager/GitReleaseManagerAliases.cs b/src/Cake.Common/Tools/GitReleaseManager/GitReleaseManagerAliases.cs index ed80fc9ab2..5737b34968 100644 --- a/src/Cake.Common/Tools/GitReleaseManager/GitReleaseManagerAliases.cs +++ b/src/Cake.Common/Tools/GitReleaseManager/GitReleaseManagerAliases.cs @@ -30,28 +30,6 @@ namespace Cake.Common.Tools.GitReleaseManager [CakeAliasCategory("GitReleaseManager")] public static class GitReleaseManagerAliases { - /// - /// Creates a Package Release. - /// - /// The context. - /// The user name. - /// The password. - /// The owner. - /// The repository. - /// - /// - /// GitReleaseManagerCreate("user", "password", "owner", "repo"); - /// - /// - [CakeMethodAlias] - [CakeAliasCategory("Create")] - [CakeNamespaceImport("Cake.Common.Tools.GitReleaseManager.Create")] - [Obsolete("Use the overload that accepts a token instead.")] - public static void GitReleaseManagerCreate(this ICakeContext context, string userName, string password, string owner, string repository) - { - GitReleaseManagerCreate(context, userName, password, owner, repository, new GitReleaseManagerCreateSettings()); - } - /// /// Creates a Package Release. /// @@ -72,55 +50,6 @@ public static void GitReleaseManagerCreate(this ICakeContext context, string tok GitReleaseManagerCreate(context, token, owner, repository, new GitReleaseManagerCreateSettings()); } - /// - /// Creates a Package Release using the specified settings. - /// - /// The context. - /// The user name. - /// The password. - /// The owner. - /// The repository. - /// The settings. - /// - /// - /// GitReleaseManagerCreate("user", "password", "owner", "repo", new GitReleaseManagerCreateSettings { - /// Milestone = "0.1.0", - /// Prerelease = false, - /// Assets = "c:/temp/asset1.txt,c:/temp/asset2.txt", - /// TargetCommitish = "master", - /// TargetDirectory = "c:/repo", - /// LogFilePath = "c:/temp/grm.log" - /// }); - /// - /// - /// - /// - /// GitReleaseManagerCreate("user", "password", "owner", "repo", new GitReleaseManagerCreateSettings { - /// Name = "0.1.0", - /// InputFilePath = "c:/repo/releasenotes.md", - /// Prerelease = false, - /// Assets = "c:/temp/asset1.txt,c:/temp/asset2.txt", - /// TargetCommitish = "master", - /// TargetDirectory = "c:/repo", - /// LogFilePath = "c:/temp/grm.log" - /// }); - /// - /// - [CakeMethodAlias] - [CakeAliasCategory("Create")] - [CakeNamespaceImport("Cake.Common.Tools.GitReleaseManager.Create")] - [Obsolete("Use the overload that accepts a token instead.")] - public static void GitReleaseManagerCreate(this ICakeContext context, string userName, string password, string owner, string repository, GitReleaseManagerCreateSettings settings) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - var creator = new GitReleaseManagerCreator(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); - creator.Create(userName, password, owner, repository, settings); - } - /// /// Creates a Package Release using the specified settings. /// @@ -168,30 +97,6 @@ public static void GitReleaseManagerCreate(this ICakeContext context, string tok creator.Create(token, owner, repository, settings); } - /// - /// Add Assets to an existing release. - /// - /// The context. - /// The user name. - /// The password. - /// The owner. - /// The repository. - /// The tag name. - /// The assets. - /// - /// - /// GitReleaseManagerAddAssets("user", "password", "owner", "repo", "0.1.0", "c:/temp/asset1.txt,c:/temp/asset2.txt"); - /// - /// - [CakeMethodAlias] - [CakeAliasCategory("AddAssets")] - [CakeNamespaceImport("Cake.Common.Tools.GitReleaseManager.AddAssets")] - [Obsolete("Use the overload that accepts a token instead.")] - public static void GitReleaseManagerAddAssets(this ICakeContext context, string userName, string password, string owner, string repository, string tagName, string assets) - { - GitReleaseManagerAddAssets(context, userName, password, owner, repository, tagName, assets, new GitReleaseManagerAddAssetsSettings()); - } - /// /// Add Assets to an existing release. /// @@ -214,40 +119,6 @@ public static void GitReleaseManagerAddAssets(this ICakeContext context, string GitReleaseManagerAddAssets(context, token, owner, repository, tagName, assets, new GitReleaseManagerAddAssetsSettings()); } - /// - /// Add Assets to an existing release using the specified settings. - /// - /// The context. - /// The user name. - /// The password. - /// The owner. - /// The repository. - /// The tag name. - /// The assets. - /// The settings. - /// - /// - /// GitReleaseManagerAddAssets("user", "password", "owner", "repo", "0.1.0", "c:/temp/asset1.txt,c:/temp/asset2.txt" new GitReleaseManagerAddAssetsSettings { - /// TargetDirectory = "c:/repo", - /// LogFilePath = "c:/temp/grm.log" - /// }); - /// - /// - [CakeMethodAlias] - [CakeAliasCategory("AddAssets")] - [CakeNamespaceImport("Cake.Common.Tools.GitReleaseManager.AddAssets")] - [Obsolete("Use the overload that accepts a token instead.")] - public static void GitReleaseManagerAddAssets(this ICakeContext context, string userName, string password, string owner, string repository, string tagName, string assets, GitReleaseManagerAddAssetsSettings settings) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - var assetsAdder = new GitReleaseManagerAssetsAdder(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); - assetsAdder.AddAssets(userName, password, owner, repository, tagName, assets, settings); - } - /// /// Add Assets to an existing release using the specified settings. /// @@ -280,29 +151,6 @@ public static void GitReleaseManagerAddAssets(this ICakeContext context, string assetsAdder.AddAssets(token, owner, repository, tagName, assets, settings); } - /// - /// Closes the milestone associated with a release. - /// - /// The context. - /// The user name. - /// The password. - /// The owner. - /// The repository. - /// The milestone. - /// - /// - /// GitReleaseManagerClose("user", "password", "owner", "repo", "0.1.0"); - /// - /// - [CakeMethodAlias] - [CakeAliasCategory("Close")] - [CakeNamespaceImport("Cake.Common.Tools.GitReleaseManager.Close")] - [Obsolete("Use the overload that accepts a token instead.")] - public static void GitReleaseManagerClose(this ICakeContext context, string userName, string password, string owner, string repository, string milestone) - { - GitReleaseManagerClose(context, userName, password, owner, repository, milestone, new GitReleaseManagerCloseMilestoneSettings()); - } - /// /// Closes the milestone associated with a release. /// @@ -324,39 +172,6 @@ public static void GitReleaseManagerClose(this ICakeContext context, string toke GitReleaseManagerClose(context, token, owner, repository, milestone, new GitReleaseManagerCloseMilestoneSettings()); } - /// - /// Closes the milestone associated with a release using the specified settings. - /// - /// The context. - /// The user name. - /// The password. - /// The owner. - /// The repository. - /// The milestone. - /// The settings. - /// - /// - /// GitReleaseManagerClose("user", "password", "owner", "repo", "0.1.0", new GitReleaseManagerCloseMilestoneSettings { - /// TargetDirectory = "c:/repo", - /// LogFilePath = "c:/temp/grm.log" - /// }); - /// - /// - [CakeMethodAlias] - [CakeAliasCategory("Close")] - [CakeNamespaceImport("Cake.Common.Tools.GitReleaseManager.Close")] - [Obsolete("Use the overload that accepts a token instead.")] - public static void GitReleaseManagerClose(this ICakeContext context, string userName, string password, string owner, string repository, string milestone, GitReleaseManagerCloseMilestoneSettings settings) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - var milestoneCloser = new GitReleaseManagerMilestoneCloser(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); - milestoneCloser.Close(userName, password, owner, repository, milestone, settings); - } - /// /// Closes the milestone associated with a release using the specified settings. /// @@ -388,29 +203,6 @@ public static void GitReleaseManagerClose(this ICakeContext context, string toke milestoneCloser.Close(token, owner, repository, milestone, settings); } - /// - /// Publishes the release. - /// - /// The context. - /// The user name. - /// The password. - /// The owner. - /// The repository. - /// The tag name. - /// - /// - /// GitReleaseManagerPublish("user", "password", "owner", "repo", "0.1.0"); - /// - /// - [CakeMethodAlias] - [CakeAliasCategory("Publish")] - [CakeNamespaceImport("Cake.Common.Tools.GitReleaseManager.Publish")] - [Obsolete("Use the overload that accepts a token instead.")] - public static void GitReleaseManagerPublish(this ICakeContext context, string userName, string password, string owner, string repository, string tagName) - { - GitReleaseManagerPublish(context, userName, password, owner, repository, tagName, new GitReleaseManagerPublishSettings()); - } - /// /// Publishes the release. /// @@ -432,39 +224,6 @@ public static void GitReleaseManagerPublish(this ICakeContext context, string to GitReleaseManagerPublish(context, token, owner, repository, tagName, new GitReleaseManagerPublishSettings()); } - /// - /// Publishes the release using the specified settings. - /// - /// The context. - /// The user name. - /// The password. - /// The owner. - /// The repository. - /// The tag name. - /// The settings. - /// - /// - /// GitReleaseManagerPublish("token", "owner", "repo", "0.1.0", new GitReleaseManagerPublishSettings { - /// TargetDirectory = "c:/repo", - /// LogFilePath = "c:/temp/grm.log" - /// }); - /// - /// - [CakeMethodAlias] - [CakeAliasCategory("Publish")] - [CakeNamespaceImport("Cake.Common.Tools.GitReleaseManager.Publish")] - [Obsolete("Use the overload that accepts a token instead.")] - public static void GitReleaseManagerPublish(this ICakeContext context, string userName, string password, string owner, string repository, string tagName, GitReleaseManagerPublishSettings settings) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - var publisher = new GitReleaseManagerPublisher(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); - publisher.Publish(userName, password, owner, repository, tagName, settings); - } - /// /// Publishes the release using the specified settings. /// @@ -496,30 +255,6 @@ public static void GitReleaseManagerPublish(this ICakeContext context, string to publisher.Publish(token, owner, repository, tagName, settings); } - /// - /// Exports the release notes. - /// - /// The context. - /// The user name. - /// The password. - /// The owner. - /// The repository. - /// The output file path. - /// - /// - /// GitReleaseManagerExport("user", "password", "owner", "repo", "c:/temp/releasenotes.md") - /// }); - /// - /// - [CakeMethodAlias] - [CakeAliasCategory("Export")] - [CakeNamespaceImport("Cake.Common.Tools.GitReleaseManager.Export")] - [Obsolete("Use the overload that accepts a token instead.")] - public static void GitReleaseManagerExport(this ICakeContext context, string userName, string password, string owner, string repository, FilePath fileOutputPath) - { - GitReleaseManagerExport(context, userName, password, owner, repository, fileOutputPath, new GitReleaseManagerExportSettings()); - } - /// /// Exports the release notes. /// @@ -542,40 +277,6 @@ public static void GitReleaseManagerExport(this ICakeContext context, string tok GitReleaseManagerExport(context, token, owner, repository, fileOutputPath, new GitReleaseManagerExportSettings()); } - /// - /// Exports the release notes using the specified settings. - /// - /// The context. - /// The user name. - /// The password. - /// The owner. - /// The repository. - /// The output file path. - /// The settings. - /// - /// - /// GitReleaseManagerExport("user", "password", "owner", "repo", "c:/temp/releasenotes.md", new GitReleaseManagerExportSettings { - /// TagName = "0.1.0", - /// TargetDirectory = "c:/repo", - /// LogFilePath = "c:/temp/grm.log" - /// }); - /// - /// - [CakeMethodAlias] - [CakeAliasCategory("Export")] - [CakeNamespaceImport("Cake.Common.Tools.GitReleaseManager.Export")] - [Obsolete("Use the overload that accepts a token instead.")] - public static void GitReleaseManagerExport(this ICakeContext context, string userName, string password, string owner, string repository, FilePath fileOutputPath, GitReleaseManagerExportSettings settings) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - var publisher = new GitReleaseManagerExporter(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); - publisher.Export(userName, password, owner, repository, fileOutputPath, settings); - } - /// /// Exports the release notes using the specified settings. /// @@ -608,29 +309,6 @@ public static void GitReleaseManagerExport(this ICakeContext context, string tok publisher.Export(token, owner, repository, fileOutputPath, settings); } - /// - /// Deletes and creates labels. - /// - /// The context. - /// The user name. - /// The password. - /// The owner. - /// The repository. - /// - /// - /// GitReleaseManagerLabel("user", "password", "owner", "repo") - /// }); - /// - /// - [CakeMethodAlias] - [CakeAliasCategory("Label")] - [CakeNamespaceImport("Cake.Common.Tools.GitReleaseManager.Label")] - [Obsolete("Use the overload that accepts a token instead.")] - public static void GitReleaseManagerLabel(this ICakeContext context, string userName, string password, string owner, string repository) - { - GitReleaseManagerLabel(context, userName, password, owner, repository, new GitReleaseManagerLabelSettings()); - } - /// /// Deletes and creates labels. /// @@ -652,37 +330,6 @@ public static void GitReleaseManagerLabel(this ICakeContext context, string toke GitReleaseManagerLabel(context, token, owner, repository, new GitReleaseManagerLabelSettings()); } - /// - /// Deletes and creates labels using the specified settings. - /// - /// The context. - /// The user name. - /// The password. - /// The owner. - /// The repository. - /// The settings. - /// - /// - /// GitReleaseManagerLabel("user", "password", "owner", "repo", new GitReleaseManagerLabelSettings { - /// LogFilePath = "c:/temp/grm.log" - /// }); - /// - /// - [CakeMethodAlias] - [CakeAliasCategory("Label")] - [CakeNamespaceImport("Cake.Common.Tools.GitReleaseManager.Label")] - [Obsolete("Use the overload that accepts a token instead.")] - public static void GitReleaseManagerLabel(this ICakeContext context, string userName, string password, string owner, string repository, GitReleaseManagerLabelSettings settings) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - var labeller = new GitReleaseManagerLabeller(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); - labeller.Label(userName, password, owner, repository, settings); - } - /// /// Deletes and creates labels using the specified settings. /// diff --git a/src/Cake.Common/Tools/MSpec/MspecSettings.cs b/src/Cake.Common/Tools/MSpec/MspecSettings.cs index a17925ca06..6e08a8e45f 100644 --- a/src/Cake.Common/Tools/MSpec/MspecSettings.cs +++ b/src/Cake.Common/Tools/MSpec/MspecSettings.cs @@ -97,25 +97,11 @@ public sealed class MSpecSettings : ToolSettings /// public bool AppVeyor { get; set; } - /// - /// Gets or sets a value indicating whether to enable reporting for AppVeyor CI integration (also auto-detected). - /// - [Obsolete("Please use the AppVeyor property instead (note the capitalization). This property will be removed in a future version.")] - [CLSCompliant(false)] // Identifier differs only in case - public bool Appveyor { get => AppVeyor; set => AppVeyor = value; } - /// /// Gets or sets a value indicating whether to disable AppVeyor autodetection. /// public bool NoAppVeyor { get; set; } - /// - /// Gets or sets a value indicating whether to disable AppVeyor autodetection. - /// - [Obsolete("Please use the NoAppVeyor property instead (note the capitalization). This property will be removed in a future version.")] - [CLSCompliant(false)] // Identifier differs only in case - public bool NoAppveyor { get => NoAppVeyor; set => NoAppVeyor = value; } - /// /// Gets or sets output directory for reports. /// diff --git a/src/Cake.Common/Tools/NUnit/NUnit3Runner.cs b/src/Cake.Common/Tools/NUnit/NUnit3Runner.cs index 162033410e..81ddb4bc5f 100644 --- a/src/Cake.Common/Tools/NUnit/NUnit3Runner.cs +++ b/src/Cake.Common/Tools/NUnit/NUnit3Runner.cs @@ -114,18 +114,6 @@ private ProcessArgumentBuilder GetArguments(IEnumerable assemblyPaths, builder.AppendQuoted(string.Format(CultureInfo.InvariantCulture, "--out={0}", settings.OutputFile.MakeAbsolute(_environment).FullPath)); } - #pragma warning disable 0618 - if (settings.ErrorOutputFile != null) - { - builder.AppendQuoted(string.Format(CultureInfo.InvariantCulture, "--err={0}", settings.ErrorOutputFile.MakeAbsolute(_environment).FullPath)); - } - - if (settings.Full) - { - builder.Append("--full"); - } - #pragma warning restore 0618 - if (HasResults(settings) && settings.NoResults) { throw new ArgumentException( @@ -173,13 +161,6 @@ private ProcessArgumentBuilder GetArguments(IEnumerable assemblyPaths, builder.Append("--nocolor"); } - #pragma warning disable 0618 - if (settings.Verbose) - { - builder.Append("--verbose"); - } - #pragma warning restore 0618 - if (settings.Configuration != null) { builder.AppendQuoted("--config=" + settings.Configuration); diff --git a/src/Cake.Common/Tools/NUnit/NUnit3Settings.cs b/src/Cake.Common/Tools/NUnit/NUnit3Settings.cs index 4ed2f06547..fca888836f 100644 --- a/src/Cake.Common/Tools/NUnit/NUnit3Settings.cs +++ b/src/Cake.Common/Tools/NUnit/NUnit3Settings.cs @@ -105,23 +105,6 @@ public sealed class NUnit3Settings : ToolSettings /// The location that NUnit should write test output. public FilePath OutputFile { get; set; } - /// - /// Gets or sets the location that NUnit should write test error output. - /// - /// The location that NUnit should write test error output. - [Obsolete("This argument was removed from NUnit3", false)] - public FilePath ErrorOutputFile { get; set; } - - /// - /// Gets or sets a value indicating whether to print full report of all test results. - /// - /// - /// true if a full report of test results should be printed; - /// otherwise, false. - /// - [Obsolete("This argument was removed from NUnit3", false)] - public bool Full { get; set; } - /// /// Gets or sets the results that should be saved. /// @@ -170,15 +153,6 @@ public sealed class NUnit3Settings : ToolSettings /// public bool NoColor { get; set; } - /// - /// Gets or sets a value indicating whether to show additional information as the tests run. - /// - /// - /// true shows additional information as the tests run; otherwise, false. - /// - [Obsolete("This argument was removed from NUnit3", false)] - public bool Verbose { get; set; } - /// /// Gets or sets the name of a project configuration to load (e.g.:Debug). /// This selects the configuration within the NUnit project file. diff --git a/src/Cake.Common/Tools/NuGet/NuGetMSBuildVersion.cs b/src/Cake.Common/Tools/NuGet/NuGetMSBuildVersion.cs index 6396f29b3a..c826f203a9 100644 --- a/src/Cake.Common/Tools/NuGet/NuGetMSBuildVersion.cs +++ b/src/Cake.Common/Tools/NuGet/NuGetMSBuildVersion.cs @@ -26,15 +26,6 @@ public enum NuGetMSBuildVersion /// MSBuild14 = 14, - /// - /// MSBuildVersion : 15 - /// - /// - /// MSBuildVersion 15 isn't an valid option and will be removed in the futute. - /// - [Obsolete("MSBuildVersion 15 isn't an valid option and will be removed in the future.")] - MSBuild15 = 15, - /// /// MSBuildVersion : 15.1 /// diff --git a/src/Cake.Common/Tools/NuGet/NuGetMSBuildVersionExtensions.cs b/src/Cake.Common/Tools/NuGet/NuGetMSBuildVersionExtensions.cs index 530ccc5bb0..9c776ea4c7 100644 --- a/src/Cake.Common/Tools/NuGet/NuGetMSBuildVersionExtensions.cs +++ b/src/Cake.Common/Tools/NuGet/NuGetMSBuildVersionExtensions.cs @@ -25,11 +25,6 @@ public static string GetNuGetMSBuildVersionString(this NuGetMSBuildVersion nuGet case NuGetMSBuildVersion.MSBuild14: return "14"; -#pragma warning disable CS0618 - case NuGetMSBuildVersion.MSBuild15: - return "15"; -#pragma warning restore CS0618 - case NuGetMSBuildVersion.MSBuild15_1: return "15.1"; diff --git a/src/Cake.Core/CakeEnvironment.cs b/src/Cake.Core/CakeEnvironment.cs index 15157a4a98..802d50439a 100644 --- a/src/Cake.Core/CakeEnvironment.cs +++ b/src/Cake.Core/CakeEnvironment.cs @@ -110,42 +110,6 @@ public IDictionary GetEnvironmentVariables() dictionary => dictionary); } - /// - /// Gets whether or not the current operative system is 64 bit. - /// - /// - /// Whether or not the current operative system is 64 bit. - /// - [Obsolete("Please use CakeEnvironment.Platform.Is64Bit instead.")] - public bool Is64BitOperativeSystem() - { - return Platform.Is64Bit; - } - - /// - /// Determines whether the current machine is running Unix. - /// - /// - /// Whether or not the current machine is running Unix. - /// - [Obsolete("Please use CakeEnvironment.Platform.IsUnix instead.")] - public bool IsUnix() - { - return Platform.IsUnix(); - } - - /// - /// Gets the application root path. - /// - /// - /// The application root path. - /// - [Obsolete("Please use CakeEnvironment.ApplicationRoot instead.")] - public DirectoryPath GetApplicationRoot() - { - return ApplicationRoot; - } - private static void SetWorkingDirectory(DirectoryPath path) { if (path.IsRelative) diff --git a/src/Cake.Core/ICakeEnvironment.cs b/src/Cake.Core/ICakeEnvironment.cs index c5f78c5514..fb8c970348 100644 --- a/src/Cake.Core/ICakeEnvironment.cs +++ b/src/Cake.Core/ICakeEnvironment.cs @@ -57,26 +57,5 @@ public interface ICakeEnvironment /// /// The runtime Cake is running in. ICakeRuntime Runtime { get; } - - /// - /// Gets whether or not the current operative system is 64 bit. - /// - /// Whether or not the current operative system is 64 bit. - [Obsolete("Please use ICakeEnvironment.Platform.Is64Bit instead.")] - bool Is64BitOperativeSystem(); - - /// - /// Determines whether the current machine is running Unix. - /// - /// Whether or not the current machine is running Unix. - [Obsolete("Please use ICakeEnvironment.Platform.IsUnix instead.")] - bool IsUnix(); - - /// - /// Gets the application root path. - /// - /// The application root path. - [Obsolete("Please use ICakeEnvironment.ApplicationRoot instead.")] - DirectoryPath GetApplicationRoot(); } } \ No newline at end of file diff --git a/src/Cake.Core/IO/Globber.cs b/src/Cake.Core/IO/Globber.cs index 3855a64d03..aeda643b3f 100644 --- a/src/Cake.Core/IO/Globber.cs +++ b/src/Cake.Core/IO/Globber.cs @@ -41,32 +41,6 @@ public Globber(IFileSystem fileSystem, ICakeEnvironment environment) _comparer = new PathComparer(environment.Platform.IsUnix()); } - /// - /// Returns instances matching the specified pattern. - /// - /// The pattern to match. - /// The predicate used to filter directories based on file system information. - /// - /// instances matching the specified pattern. - /// - [Obsolete("Please use the Match overload that accept globber settings instead.", false)] - public IEnumerable Match(string pattern, Func predicate) - { - if (pattern == null) - { - throw new ArgumentNullException(nameof(pattern)); - } - if (string.IsNullOrWhiteSpace(pattern)) - { - return Enumerable.Empty(); - } - - return Match(pattern, new GlobberSettings - { - Predicate = predicate - }); - } - /// /// Returns instances matching the specified pattern. /// diff --git a/src/Cake.Core/IO/IGlobber.cs b/src/Cake.Core/IO/IGlobber.cs index 47482b13ad..3c75aa37a8 100644 --- a/src/Cake.Core/IO/IGlobber.cs +++ b/src/Cake.Core/IO/IGlobber.cs @@ -12,17 +12,6 @@ namespace Cake.Core.IO /// public interface IGlobber { - /// - /// Returns instances matching the specified pattern. - /// - /// The pattern to match. - /// The predicate used to filter directories based on file system information. - /// - /// instances matching the specified pattern. - /// - [Obsolete("Please use the Match overload that accept globber settings instead.", false)] - IEnumerable Match(string pattern, Func predicate); - /// /// Returns instances matching the specified pattern. /// diff --git a/src/Cake.Core/Properties/Namespaces.cs b/src/Cake.Core/Properties/Namespaces.cs index 84a83a6495..55b220ea65 100644 --- a/src/Cake.Core/Properties/Namespaces.cs +++ b/src/Cake.Core/Properties/Namespaces.cs @@ -134,18 +134,4 @@ namespace Cake.Core.Tooling internal class NamespaceDoc { } -} - -// ReSharper disable once CheckNamespace -namespace Cake.Core.Utilities -{ - /// - /// This namespace contain base classes - /// and functionality related to tooling. - /// The content in this namespace has been obsoleted. - /// - [CompilerGenerated] - internal class NamespaceDoc - { - } } \ No newline at end of file diff --git a/src/Cake.Core/Scripting/CodeGen/MethodAliasGenerator.cs b/src/Cake.Core/Scripting/CodeGen/MethodAliasGenerator.cs index 44dfb3e370..570d52b097 100644 --- a/src/Cake.Core/Scripting/CodeGen/MethodAliasGenerator.cs +++ b/src/Cake.Core/Scripting/CodeGen/MethodAliasGenerator.cs @@ -18,7 +18,7 @@ namespace Cake.Core.Scripting.CodeGen /// public static class MethodAliasGenerator { - private static readonly System.Security.Cryptography.SHA256 SHA256 = System.Security.Cryptography.SHA256.Create(); + private static readonly System.Security.Cryptography.SHA256 _hasher = System.Security.Cryptography.SHA256.Create(); /// /// Generates a script method alias from the specified method. @@ -71,7 +71,7 @@ public static string Generate(MethodInfo method, out string hash) GenericParameterConstraintEmitter.BuildGenericConstraints(method, builder); } - hash = SHA256 + hash = _hasher .ComputeHash(Encoding.UTF8.GetBytes(builder.ToString())) .Aggregate(new StringBuilder(), (sb, b) => sb.AppendFormat("{0:x2}", b), diff --git a/src/Cake.Core/Tooling/Tool.cs b/src/Cake.Core/Tooling/Tool.cs index 9cb706a75c..f47aadfb2a 100644 --- a/src/Cake.Core/Tooling/Tool.cs +++ b/src/Cake.Core/Tooling/Tool.cs @@ -19,29 +19,9 @@ public abstract class Tool where TSettings : ToolSettings { private readonly ICakeEnvironment _environment; private readonly IFileSystem _fileSystem; - private readonly IGlobber _globber; private readonly IToolLocator _tools; private readonly IProcessRunner _processRunner; - /// - /// Initializes a new instance of the class. - /// - /// The file system. - /// The environment. - /// The process runner. - /// The globber. - [Obsolete("Please use Tool(IFileSystem, ICakeEnvironment, IProcessRunner, IToolLocator) instead.")] - protected Tool(IFileSystem fileSystem, ICakeEnvironment environment, IProcessRunner processRunner, IGlobber globber) - : this(fileSystem, environment, processRunner, (IToolLocator)null) - { - if (globber == null) - { - throw new ArgumentNullException(nameof(globber)); - } - - _globber = globber; - } - /// /// Initializes a new instance of the class. /// @@ -279,12 +259,7 @@ protected virtual IDictionary GetEnvironmentVariables(TSettings /// The resolved tool path. protected FilePath GetToolPath(TSettings settings) { - if (_tools != null) - { - return GetToolPathUsingToolService(settings); - } - - return GetToolPathObsolete(settings); + return GetToolPathUsingToolService(settings); } private FilePath GetToolPathUsingToolService(TSettings settings) @@ -314,63 +289,5 @@ private FilePath GetToolPathUsingToolService(TSettings settings) return null; } - - [SuppressMessage("ReSharper", "ConvertIfStatementToConditionalTernaryExpression")] - private FilePath GetToolPathObsolete(TSettings settings) - { - var toolPath = settings.ToolPath; - if (toolPath != null) - { - return toolPath.MakeAbsolute(_environment); - } - - // Look for each possible executable name in various places. - string[] pathDirs = null; - foreach (var toolExeName in GetToolExecutableNames(settings)) - { - // First look in ./tools/ - toolPath = _globber.GetFiles("./tools/**/" + toolExeName).FirstOrDefault(); - if (toolPath != null) - { - return toolPath.MakeAbsolute(_environment); - } - - // Cache the PATH directory list if we didn't already. - if (pathDirs == null) - { - var pathEnv = _environment.GetEnvironmentVariable("PATH"); - if (!string.IsNullOrEmpty(pathEnv)) - { - pathDirs = pathEnv.Split(new[] { _environment.Platform.IsUnix() ? ':' : ';' }, StringSplitOptions.RemoveEmptyEntries); - } - else - { - pathDirs = new string[] { }; - } - } - - // Look in every PATH directory for the file. - foreach (var pathDir in pathDirs) - { - var file = new DirectoryPath(pathDir).CombineWithFilePath(toolExeName); - if (_fileSystem.Exist(file)) - { - return file.MakeAbsolute(_environment); - } - } - } - - // Look through all the alternative directories for the tool. - var alternativePaths = GetAlternativeToolPaths(settings) ?? Enumerable.Empty(); - foreach (var altPath in alternativePaths) - { - if (_fileSystem.Exist(altPath)) - { - return altPath.MakeAbsolute(_environment); - } - } - - return null; - } } } \ No newline at end of file diff --git a/src/Cake.Core/Utilities/Tool.cs b/src/Cake.Core/Utilities/Tool.cs deleted file mode 100644 index 1c1db7ecae..0000000000 --- a/src/Cake.Core/Utilities/Tool.cs +++ /dev/null @@ -1,289 +0,0 @@ -// 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; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.Linq; -using Cake.Core.IO; - -namespace Cake.Core.Utilities -{ - /// - /// Base class for tools. - /// - /// The settings type. - [Obsolete("Please use Cake.Core.Tooling.Tool instead.")] - public abstract class Tool - { - private readonly ICakeEnvironment _environment; - private readonly IFileSystem _fileSystem; - private readonly IGlobber _globber; - private readonly IProcessRunner _processRunner; - - /// - /// Initializes a new instance of the class. - /// - /// The file system. - /// The environment. - /// The process runner. - /// The globber. - protected Tool(IFileSystem fileSystem, ICakeEnvironment environment, IProcessRunner processRunner, - IGlobber globber) - { - if (fileSystem == null) - { - throw new ArgumentNullException(nameof(fileSystem)); - } - if (environment == null) - { - throw new ArgumentNullException(nameof(environment)); - } - if (processRunner == null) - { - throw new ArgumentNullException(nameof(processRunner)); - } - if (globber == null) - { - throw new ArgumentNullException(nameof(globber)); - } - - _fileSystem = fileSystem; - _environment = environment; - _processRunner = processRunner; - _globber = globber; - } - - /// - /// Runs the tool using the specified settings. - /// - /// The settings. - /// The arguments. - protected void Run(TSettings settings, ProcessArgumentBuilder arguments) - { - Run(settings, arguments, null); - } - - /// - /// Runs the tool using a custom tool path and the specified settings. - /// - /// The settings. - /// The arguments. - /// The tool path to use. - protected void Run(TSettings settings, ProcessArgumentBuilder arguments, FilePath toolPath) - { - Run(settings, arguments, toolPath, null, null); - } - - /// - /// Runs the tool using a custom tool path and the specified settings. - /// - /// The settings. - /// The arguments. - /// The tool path to use. - /// The process settings. - /// If specified called after process exit. - protected void Run(TSettings settings, ProcessArgumentBuilder arguments, FilePath toolPath, - ProcessSettings processSettings, Action postAction) - { - if (arguments == null && (processSettings?.Arguments == null)) - { - throw new ArgumentNullException(nameof(arguments)); - } - - var process = RunProcess(settings, arguments, toolPath, processSettings); - - // Wait for the process to exit. - process.WaitForExit(); - - // Post action specified? - postAction?.Invoke(process); - - // Did an error occur? - if (process.GetExitCode() != 0) - { - const string message = "{0}: Process returned an error (exit code {1})."; - throw new CakeException(string.Format(CultureInfo.InvariantCulture, message, GetToolName(), process.GetExitCode())); - } - } - - /// - /// Runs the tool using a custom tool path and the specified settings. - /// - /// The settings. - /// The arguments. - /// The process that the tool is running under. - protected IProcess RunProcess(TSettings settings, ProcessArgumentBuilder arguments) - { - return RunProcess(settings, arguments, null); - } - - /// - /// Runs the tool using a custom tool path and the specified settings. - /// - /// The settings. - /// The arguments. - /// The tool path to use. - /// The process that the tool is running under. - protected IProcess RunProcess(TSettings settings, ProcessArgumentBuilder arguments, FilePath toolPath) - { - return RunProcess(settings, arguments, toolPath, null); - } - - /// - /// Runs the tool using a custom tool path and the specified settings. - /// - /// The settings. - /// The arguments. - /// The tool path to use. - /// The process settings. - /// The process that the tool is running under. - protected IProcess RunProcess(TSettings settings, ProcessArgumentBuilder arguments, FilePath toolPath, - ProcessSettings processSettings) - { - if (arguments == null && (processSettings?.Arguments == null)) - { - throw new ArgumentNullException(nameof(arguments)); - } - - // Get the tool name. - var toolName = GetToolName(); - - // Get the tool path. - toolPath = GetToolPath(settings, toolPath); - if (toolPath == null || !_fileSystem.Exist(toolPath)) - { - const string message = "{0}: Could not locate executable."; - throw new CakeException(string.Format(CultureInfo.InvariantCulture, message, toolName)); - } - - // Get the working directory. - var workingDirectory = GetWorkingDirectory(settings); - if (workingDirectory == null) - { - const string message = "{0}: Could not resolve working directory."; - throw new CakeException(string.Format(CultureInfo.InvariantCulture, message, toolName)); - } - - // Create the process start info. - var info = processSettings ?? new ProcessSettings(); - if (info.Arguments == null) - { - info.Arguments = arguments; - } - if (info.WorkingDirectory == null) - { - info.WorkingDirectory = workingDirectory.MakeAbsolute(_environment).FullPath; - } - - // Run the process. - var process = _processRunner.Start(toolPath, info); - if (process == null) - { - const string message = "{0}: Process was not started."; - throw new CakeException(string.Format(CultureInfo.InvariantCulture, message, toolName)); - } - return process; - } - - /// - /// Gets the tool path. - /// - /// The settings. - /// The provided tool path (if any). - /// The tool path. - [SuppressMessage("ReSharper", "ConvertIfStatementToConditionalTernaryExpression")] - protected FilePath GetToolPath(TSettings settings, FilePath toolPath) - { - if (toolPath != null) - { - return toolPath.MakeAbsolute(_environment); - } - - var toolExeNames = GetToolExecutableNames(); - string[] pathDirs = null; - - // Look for each possible executable name in various places. - foreach (var toolExeName in toolExeNames) - { - // First look in ./tools/ - toolPath = _globber.GetFiles("./tools/**/" + toolExeName).FirstOrDefault(); - if (toolPath != null) - { - return toolPath.MakeAbsolute(_environment); - } - - // Cache the PATH directory list if we didn't already. - if (pathDirs == null) - { - var pathEnv = _environment.GetEnvironmentVariable("PATH"); - if (!string.IsNullOrEmpty(pathEnv)) - { - pathDirs = pathEnv.Split(new[] { _environment.IsUnix() ? ':' : ';' }, StringSplitOptions.RemoveEmptyEntries); - } - else - { - pathDirs = new string[] { }; - } - } - - // Look in every PATH directory for the file. - foreach (var pathDir in pathDirs) - { - var file = new DirectoryPath(pathDir).CombineWithFilePath(toolExeName); - if (_fileSystem.Exist(file)) - { - return file.MakeAbsolute(_environment); - } - } - } - - // Look through all the alternative directories for the tool. - var alternativePaths = GetAlternativeToolPaths(settings) ?? Enumerable.Empty(); - foreach (var altPath in alternativePaths) - { - if (_fileSystem.Exist(altPath)) - { - return altPath.MakeAbsolute(_environment); - } - } - - return null; - } - - /// - /// Gets the name of the tool. - /// - /// The name of the tool. - protected abstract string GetToolName(); - - /// - /// Gets the possible names of the tool executable. - /// - /// The tool executable name. - protected abstract IEnumerable GetToolExecutableNames(); - - /// - /// Gets the working directory. - /// Defaults to the currently set working directory. - /// - /// The settings. - /// The working directory for the tool. - protected virtual DirectoryPath GetWorkingDirectory(TSettings settings) - { - return _environment.WorkingDirectory; - } - - /// - /// Gets alternative file paths which the tool may exist in. - /// - /// The settings. - /// The default tool path. - protected virtual IEnumerable GetAlternativeToolPaths(TSettings settings) - { - return Enumerable.Empty(); - } - } -} \ No newline at end of file diff --git a/src/Cake.Testing/FakeEnvironment.cs b/src/Cake.Testing/FakeEnvironment.cs index 4f227e977a..aca491543d 100644 --- a/src/Cake.Testing/FakeEnvironment.cs +++ b/src/Cake.Testing/FakeEnvironment.cs @@ -191,47 +191,5 @@ public void SetIsCoreClr(bool isCoreClr) { Runtime.IsCoreClr = isCoreClr; } - - /// - /// Gets whether or not the current operative system is 64 bit. - /// - /// Whether or not the current operative system is 64 bit. - [Obsolete("Please use FakeEnvironment.Platform.Is64Bit instead.")] - public bool Is64BitOperativeSystem() - { - return Platform.Is64Bit; - } - - /// - /// Determines whether the current machine is running Unix. - /// - /// Whether or not the current machine is running Unix. - [Obsolete("Please use FakeEnvironment.Platform.IsUnix instead.")] - public bool IsUnix() - { - return Platform.IsUnix(); - } - - /// - /// Gets the application root path. - /// - /// - /// The application root path. - /// - [Obsolete("Please use FakeEnvironment.ApplicationRoot instead.")] - public DirectoryPath GetApplicationRoot() - { - return ApplicationRoot; - } - - /// - /// Gets the target .Net framework version that the current AppDomain is targeting. - /// - /// The target framework. - [Obsolete("Please use FakeEnvironment.Runtime.TargetFramework instead.")] - public FrameworkName GetBuiltFramework() - { - return Runtime.BuiltFramework; - } } } \ No newline at end of file diff --git a/tests/integration/Cake.Common/IO/DirectoryAliases.cake b/tests/integration/Cake.Common/IO/DirectoryAliases.cake index 387dad053b..54e9dcb67e 100644 --- a/tests/integration/Cake.Common/IO/DirectoryAliases.cake +++ b/tests/integration/Cake.Common/IO/DirectoryAliases.cake @@ -44,7 +44,7 @@ Task("Cake.Common.IO.DirectoryAliases.CleanDirectory.Filter") var file2 = path.CombineWithFilePath("bar.qux"); EnsureDirectoryExist(path); EnsureFilesExist(new FilePath[] { file1, file2 }); - + // When CleanDirectory(path, f => f.Path.FullPath.EndsWith("baz")); @@ -95,10 +95,13 @@ Task("Cake.Common.IO.DirectoryAliases.DeleteDirectory") // Given var path = Paths.Temp.Combine("./hello"); EnsureDirectoryExist(path); - + // When - DeleteDirectory(path, false); - + DeleteDirectory(path, + new DeleteDirectorySettings { + Force = true + }); + // Then Assert.False(System.IO.Directory.Exists(path.FullPath)); }); @@ -108,12 +111,16 @@ Task("Cake.Common.IO.DirectoryAliases.DeleteDirectory.Recurse") { // Given var root = Paths.Temp.Combine("./hello"); - var path = root.Combine("world"); + var path = root.Combine("world"); EnsureDirectoryExist(path); - + // When - DeleteDirectory(root, true); - + DeleteDirectory(root, + new DeleteDirectorySettings { + Force = true, + Recursive = true + }); + // Then Assert.False(System.IO.Directory.Exists(path.FullPath)); }); @@ -125,10 +132,13 @@ Task("Cake.Common.IO.DirectoryAliases.DeleteDirectories") var path1 = Paths.Temp.Combine("./hello"); var path2 = Paths.Temp.Combine("./world"); EnsureDirectoriesExist(new DirectoryPath[] { path1, path2 }); - + // When - DeleteDirectories(new DirectoryPath[] { path1, path2 }, false); - + DeleteDirectories(new DirectoryPath[] { path1, path2 }, + new DeleteDirectorySettings { + Force = true + }); + // Then Assert.False(System.IO.Directory.Exists(path1.FullPath)); Assert.False(System.IO.Directory.Exists(path2.FullPath)); @@ -143,10 +153,14 @@ Task("Cake.Common.IO.DirectoryAliases.DeleteDirectories.Recurse") var root2 = Paths.Temp.Combine("./baz"); var path2 = root2.Combine("qux"); EnsureDirectoriesExist(new DirectoryPath[] { root1, path1, root2, path2 }); - + // When - DeleteDirectories(new DirectoryPath[] { root1, root2 }, true); - + DeleteDirectories(new DirectoryPath[] { root1, root2 }, + new DeleteDirectorySettings { + Force = true, + Recursive = true + }); + // Then Assert.False(System.IO.Directory.Exists(path1.FullPath)); Assert.False(System.IO.Directory.Exists(path2.FullPath)); diff --git a/tests/integration/Cake.Core/Scripting/AddinDirective.cake b/tests/integration/Cake.Core/Scripting/AddinDirective.cake index 092a777ba7..f797c664d5 100644 --- a/tests/integration/Cake.Core/Scripting/AddinDirective.cake +++ b/tests/integration/Cake.Core/Scripting/AddinDirective.cake @@ -1,4 +1,4 @@ -#addin nuget:?package=Cake.Incubator&version=5.1.0 +#addin nuget:?package=Cake.Kudu.Client&version=0.9.0 Task("Cake.Core.Scripting.AddinDirective.LoadNetStandardAddin") .Does(() =>