From 993cdf9f259f08b7fc47b718a6bfce6c2b8f4c51 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Sun, 10 Oct 2021 02:12:00 +0200 Subject: [PATCH] (GH-3572) Only build TargetFrameworks netcoreapp3.1, net5.0 & net6.0 * fixes #3572 --- .github/workflows/build.yml | 5 - .travis.yml | 32 -- Directory.Build.props | 5 - appveyor.yml | 1 - build.cake | 319 ++---------------- build/credentials.cake | 56 +-- build/packages.cake | 56 +-- build/parameters.cake | 16 +- build/paths.cake | 103 +----- build/version.cake | 29 +- nuspec/Cake.CoreCLR.nuspec | 21 -- nuspec/Cake.Portable.nuspec | 23 -- nuspec/Cake.nuspec | 21 -- nuspec/VERIFICATION.txt | 7 - src/Cake.Cli/Cake.Cli.csproj | 1 - .../Cake.Common.Tests.csproj | 4 - .../Unit/XML/XmlTransformationTests.cs | 19 -- src/Cake.Common/Cake.Common.csproj | 12 - src/Cake.Common/Tools/Cake/CakeRunner.cs | 11 - src/Cake.Common/Xml/XmlTransformation.cs | 4 - src/Cake.Core.Tests/Cake.Core.Tests.csproj | 1 - src/Cake.Core.Tests/Unit/CakeRuntimeTests.cs | 17 - .../Unit/IO/ProcessRunnerTests.cs | 4 - .../Unit/Scripting/ScriptRunnerTests.cs | 23 -- src/Cake.Core/Cake.Core.csproj | 13 +- src/Cake.Core/CakeException.cs | 18 - src/Cake.Core/IO/ProcessRunner.cs | 2 - src/Cake.Core/Polyfill/AssemblyHelper.cs | 2 - src/Cake.Core/Polyfill/EnvironmentHelper.cs | 45 +-- src/Cake.Core/Polyfill/MacOSXNative.cs | 62 ---- src/Cake.Core/Polyfill/ProcessHelper.cs | 7 +- src/Cake.Core/Polyfill/SpecialPathHelper.cs | 21 +- src/Cake.Core/Polyfill/UnixNative.cs | 4 +- src/Cake.Core/Polyfill/WindowsNative.cs | 4 +- src/Cake.Core/Scripting/ScriptAliasFinder.cs | 7 - src/Cake.Core/Scripting/ScriptConventions.cs | 33 +- .../Cake.DotNetTool.Module.Tests.csproj | 1 - .../Cake.DotNetTool.Module.csproj | 7 +- .../Cake.Frosting.Example.csproj | 1 - .../Cake.Frosting.Tests.csproj | 12 - src/Cake.Frosting/Cake.Frosting.csproj | 1 - src/Cake.NuGet.Tests/Cake.NuGet.Tests.csproj | 7 - .../Unit/NuGetContentResolverTests.cs | 22 -- src/Cake.NuGet.Tests/Unit/NuGetModuleTests.cs | 17 - src/Cake.NuGet/Cake.NuGet.csproj | 1 - .../Installers/OutOfProcessInstaller.cs | 5 - src/Cake.NuGet/NuGetContentResolver.cs | 4 - .../Cake.Testing.Xunit.csproj | 1 - src/Cake.Testing.Xunit/RuntimeFact.cs | 26 -- src/Cake.Testing.Xunit/RuntimeTheory.cs | 27 -- src/Cake.Testing/Cake.Testing.csproj | 1 - .../Extensions/FakeFileExtensions.cs | 4 - src/Cake.Tests/Cake.Tests.csproj | 8 +- src/Cake/Cake.csproj | 8 +- .../Scripting/RoslynScriptSession.cs | 4 - src/Cake/Program.cs | 11 +- src/Directory.Build.props | 2 - src/Shared.msbuild | 3 +- .../Cake.Common/ArgumentAliases.cake | 14 +- .../Cake.Common/ProcessAliases.cake | 11 +- .../Cake.Core/Scripting/AddinDirective.cake | 33 +- .../Cake.Frosting/build/Build.csproj | 2 +- .../DotNetCore/hwapp.tests/hwapp.tests.csproj | 7 +- .../MyCakeExtension.cs | 0 .../Cake.Core/Scripting/addin/addin.csproj | 7 + .../netstandard2.addin.csproj | 11 - 66 files changed, 148 insertions(+), 1118 deletions(-) delete mode 100644 .travis.yml delete mode 100644 Directory.Build.props delete mode 100644 nuspec/Cake.CoreCLR.nuspec delete mode 100644 nuspec/Cake.Portable.nuspec delete mode 100644 nuspec/Cake.nuspec delete mode 100644 nuspec/VERIFICATION.txt delete mode 100644 src/Cake.Core/Polyfill/MacOSXNative.cs delete mode 100644 src/Cake.Testing.Xunit/RuntimeFact.cs delete mode 100644 src/Cake.Testing.Xunit/RuntimeTheory.cs rename tests/integration/resources/Cake.Core/Scripting/{netstandard2.addin => addin}/MyCakeExtension.cs (100%) create mode 100644 tests/integration/resources/Cake.Core/Scripting/addin/addin.csproj delete mode 100644 tests/integration/resources/Cake.Core/Scripting/netstandard2.addin/netstandard2.addin.csproj diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d1066da34e..dcbcabb140 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,11 +21,6 @@ jobs: - name: Fetch all history for all tags and branches run: git fetch --prune --unshallow - - name: Install .NET Core SDK 2.1.x - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '2.1.x' - - name: Install .NET Core SDK 3.1.x uses: actions/setup-dotnet@v1 with: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b3395c06eb..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ -language: csharp -os: - - osx - - linux - -# Ubuntu 16.04 -sudo: required -dist: bionic - -# OS X 10.12 -osx_image: xcode11.2 - -mono: - - 5.12.0 - - 5.20.1 - -dotnet: 5.0.203 - -before_install: - - git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags - - git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" - - git fetch origin - -script: - - ./build.sh --target="Travis" - -cache: - directories: - - .packages - - tools/Addins - - tools/gitreleasemanager - - tools/GitVersion.CommandLine \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props deleted file mode 100644 index bd354b1cf0..0000000000 --- a/Directory.Build.props +++ /dev/null @@ -1,5 +0,0 @@ - - - false - - diff --git a/appveyor.yml b/appveyor.yml index da94bc4e70..0275dc7372 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,7 +7,6 @@ init: build_script: - ps: Invoke-RestMethod -Uri 'https://dot.net/v1/dotnet-install.ps1' -OutFile '.\dotnet-install.ps1' - ps: New-Item -Path .\.dotnet -ItemType Directory -Force | Out-Null - - ps: .\dotnet-install.ps1 -Channel 2.1 -InstallDir .\.dotnet - ps: .\dotnet-install.ps1 -Channel 3.1 -InstallDir .\.dotnet - ps: .\dotnet-install.ps1 -Channel 5.0 -InstallDir .\.dotnet - ps: .\build.ps1 --target="AppVeyor" diff --git a/build.cake b/build.cake index adff3bd811..fba0e0d50d 100644 --- a/build.cake +++ b/build.cake @@ -1,14 +1,7 @@ // Install addins. -#addin "nuget:https://api.nuget.org/v3/index.json?package=Cake.Coveralls&version=1.0.0" #addin "nuget:https://api.nuget.org/v3/index.json?package=Cake.Twitter&version=1.0.0" #addin "nuget:https://api.nuget.org/v3/index.json?package=Cake.Gitter&version=1.0.1" -// Install tools. -#tool "nuget:https://api.nuget.org/v3/index.json?package=coveralls.io&version=1.4.2" -#tool "nuget:https://api.nuget.org/v3/index.json?package=OpenCover&version=4.7.922" -#tool "nuget:https://api.nuget.org/v3/index.json?package=ReportGenerator&version=4.7.1" -#tool "nuget:https://api.nuget.org/v3/index.json?package=NuGet.CommandLine&version=5.11.0" - // Install .NET Core Global tools. #tool "dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=5.7.0" #tool "dotnet:https://api.nuget.org/v3/index.json?package=SignClient&version=1.2.109" @@ -44,24 +37,6 @@ Setup(context => new AssemblyInfoSettings { Description = parameters.Version.SemVersion }); } - if(!parameters.IsRunningOnWindows) - { - var frameworkPathOverride = context.Environment.Runtime.IsCoreClr - ? new []{ - new DirectoryPath("/Library/Frameworks/Mono.framework/Versions/Current/lib/mono"), - new DirectoryPath("/usr/lib/mono"), - new DirectoryPath("/usr/local/lib/mono") - } - .Select(directory =>directory.Combine("4.5")) - .FirstOrDefault(directory => context.DirectoryExists(directory)) - ?.FullPath + "/" - : new FilePath(typeof(object).Assembly.Location).GetDirectory().FullPath + "/"; - - // Use FrameworkPathOverride when not running on Windows. - Information("Build will use FrameworkPathOverride={0} since not building on Windows.", frameworkPathOverride); - parameters.MSBuildSettings.WithProperty("FrameworkPathOverride", frameworkPathOverride); - } - return parameters; }); @@ -73,25 +48,25 @@ Teardown((context, parameters) => { if(parameters.ShouldPublish) { + var message = $"Version {parameters.Version.SemVersion} of Cake has just been released, https://www.nuget.org/packages/Cake.Tool/{parameters.Version.SemVersion} 🎉"; + if(parameters.CanPostToTwitter) { - var message = "Version " + parameters.Version.SemVersion + " of Cake has just been released, https://www.nuget.org/packages/Cake."; - TwitterSendTweet(parameters.Twitter.ConsumerKey, parameters.Twitter.ConsumerSecret, parameters.Twitter.AccessToken, parameters.Twitter.AccessTokenSecret, message); } if(parameters.CanPostToGitter) { - var message = "@/all Version " + parameters.Version.SemVersion + " of the Cake has just been released, https://www.nuget.org/packages/Cake."; + var gitterMessage = $"@/all {message}"; var postMessageResult = Gitter.Chat.PostMessage( - message: message, + message: gitterMessage, messageSettings: new GitterChatMessageSettings { Token = parameters.Gitter.Token, RoomId = parameters.Gitter.RoomId} ); if (postMessageResult.Ok) { - Information("Message {0} succcessfully sent", postMessageResult.TimeStamp); + Information("Message {0} successfully sent", postMessageResult.TimeStamp); } else { @@ -148,7 +123,7 @@ Task("Run-Unit-Tests") () => GetFiles("./src/**/*.Tests.csproj"), (parameters, project, context) => { - foreach(var framework in new[] { "netcoreapp2.1", "netcoreapp3.1", "net461", "net5.0", "net6.0" }) + foreach(var framework in new[] { "netcoreapp3.1", "net5.0", "net6.0" }) { FilePath testResultsPath = MakeAbsolute(parameters.Paths.Directories.TestResults .CombineWithFilePath($"{project.GetFilenameWithoutExtension()}_{framework}_TestResults.xml")); @@ -164,135 +139,8 @@ Task("Run-Unit-Tests") } }); -Task("Copy-Files") - .IsDependentOn("Run-Unit-Tests") - .Does((context, parameters) => -{ - // .NET 4.6 - DotNetCorePublish("./src/Cake/Cake.csproj", new DotNetCorePublishSettings - { - Framework = "net461", - NoRestore = true, - VersionSuffix = parameters.Version.DotNetAsterix, - Configuration = parameters.Configuration, - OutputDirectory = parameters.Paths.Directories.ArtifactsBinFullFx, - MSBuildSettings = parameters.MSBuildSettings - }); - - // .NET Core - DotNetCorePublish("./src/Cake/Cake.csproj", new DotNetCorePublishSettings - { - Framework = "netcoreapp2.1", - NoRestore = true, - Configuration = parameters.Configuration, - OutputDirectory = parameters.Paths.Directories.ArtifactsBinNetCore, - MSBuildSettings = parameters.MSBuildSettings - }); - - // Copy license - CopyFileToDirectory("./LICENSE", parameters.Paths.Directories.ArtifactsBinFullFx); - CopyFileToDirectory("./LICENSE", parameters.Paths.Directories.ArtifactsBinNetCore); - - // Copy icon - CopyFileToDirectory("./nuspec/cake-medium.png", parameters.Paths.Directories.ArtifactsBinFullFx); - CopyFileToDirectory("./nuspec/cake-medium.png", parameters.Paths.Directories.ArtifactsBinNetCore); - - // copy NuGet.org-specific ReadMe - CopyFileToDirectory("./nuspec/NuGet.org.md", parameters.Paths.Directories.ArtifactsBinFullFx); - CopyFileToDirectory("./nuspec/NuGet.org.md", parameters.Paths.Directories.ArtifactsBinNetCore); -}); - -Task("Validate-Version") - .IsDependentOn("Copy-Files") - .Does((context, parameters) => -{ - var fullFxExe = MakeAbsolute(parameters.Paths.Directories.ArtifactsBinFullFx.CombineWithFilePath("Cake.exe")); - var coreFxExe = MakeAbsolute(parameters.Paths.Directories.ArtifactsBinNetCore.CombineWithFilePath("Cake.dll")); - - context.Information("Testing {0} version...", fullFxExe); - IEnumerable fullFxOutput; - var fullFxResult = StartProcess( - fullFxExe, - new ProcessSettings { - Arguments = "--version", - RedirectStandardOutput = true, - WorkingDirectory = parameters.Paths.Directories.ArtifactsBinFullFx - }, - out fullFxOutput - ); - var fullFxVersion = string.Concat(fullFxOutput); - - context.Information("Testing {0} version...", coreFxExe); - IEnumerable coreFxOutput; - var coreFxResult = StartProcess( - context.Tools.Resolve("dotnet") ?? context.Tools.Resolve("dotnet.exe"), - new ProcessSettings { - Arguments = $"\"{coreFxExe}\" --version", - RedirectStandardOutput = true, - WorkingDirectory = parameters.Paths.Directories.ArtifactsBinNetCore - }, - out coreFxOutput - ); - var coreFxVersion = string.Concat(coreFxOutput); - - Information("{0}, ExitCode: {1}, Version: {2}", - fullFxExe, - fullFxResult, - string.Concat(fullFxVersion) - ); - - Information("{0}, ExitCode: {1}, Version: {2}", - coreFxExe, - coreFxResult, - string.Concat(coreFxVersion) - ); - - if (parameters.Version.SemVersion != fullFxVersion || parameters.Version.SemVersion != coreFxVersion) - { - throw new Exception( - $"Invalid version, expected \"{parameters.Version.SemVersion}\", got .NET \"{fullFxVersion}\" and .NET Core \"{coreFxVersion}\""); - } -}); - -Task("Zip-Files") - .IsDependentOn("Validate-Version") - .Does((context, parameters) => -{ - // .NET 4.6 - var homebrewFiles = GetFiles( parameters.Paths.Directories.ArtifactsBinFullFx.FullPath + "/**/*"); - Zip(parameters.Paths.Directories.ArtifactsBinFullFx, parameters.Paths.Files.ZipArtifactPathDesktop, homebrewFiles); - - // .NET Core - var coreclrFiles = GetFiles( parameters.Paths.Directories.ArtifactsBinNetCore.FullPath + "/**/*"); - Zip(parameters.Paths.Directories.ArtifactsBinNetCore, parameters.Paths.Files.ZipArtifactPathCoreClr, coreclrFiles); -}); - -Task("Create-Chocolatey-Packages") - .IsDependentOn("Validate-Version") - .IsDependentOn("Package") - .WithCriteria((context, parameters) => parameters.IsRunningOnWindows) - .Does((context, parameters) => -{ - foreach(var package in parameters.Packages.Chocolatey) - { - var netFxFullArtifactPath = MakeAbsolute(parameters.Paths.Directories.ArtifactsBinFullFx).FullPath; - var curDirLength = MakeAbsolute(Directory("./")).FullPath.Length + 1; - - // Create package. - ChocolateyPack(package.NuspecPath, new ChocolateyPackSettings { - Version = parameters.Version.SemVersion, - ReleaseNotes = parameters.ReleaseNotes.Notes.ToArray(), - OutputDirectory = parameters.Paths.Directories.NuGetRoot, - Files = (GetFiles(netFxFullArtifactPath + "/*.*") + GetFiles("./nuspec/*.txt") + GetFiles("./LICENSE")) - .Select(file=>"../" + file.FullPath.Substring(curDirLength)) - .Select(file=> new ChocolateyNuSpecContent { Source = file }) - .ToArray() - }); - } -}); - Task("Create-NuGet-Packages") - .IsDependentOn("Validate-Version") + .IsDependentOn("Run-Unit-Tests") .Does((context, parameters) => { // Build libraries @@ -300,7 +148,7 @@ Task("Create-NuGet-Packages") foreach(var project in projects) { var name = project.GetDirectory().FullPath; - if(name.EndsWith("Cake") || name.EndsWith("Tests") || name.EndsWith("Example")) + if(name.EndsWith("Tests") || name.EndsWith("Example")) { continue; } @@ -313,50 +161,9 @@ Task("Create-NuGet-Packages") MSBuildSettings = parameters.MSBuildSettings }); } - - var netFxFullArtifactPath = MakeAbsolute(parameters.Paths.Directories.ArtifactsBinFullFx).FullPath; - var netFxFullArtifactPathLength = netFxFullArtifactPath.Length+1; - - // Cake - .NET 4.6.1 - NuGetPack("./nuspec/Cake.nuspec", new NuGetPackSettings { - Version = parameters.Version.SemVersion, - ReleaseNotes = parameters.ReleaseNotes.Notes.ToArray(), - BasePath = netFxFullArtifactPath, - OutputDirectory = parameters.Paths.Directories.NuGetRoot, - NoPackageAnalysis = true, - Files = GetFiles(netFxFullArtifactPath + "/*") - .Select(file=>file.FullPath.Substring(netFxFullArtifactPathLength)) - .Select(file=> new NuSpecContent { Source = file, Target = file }) - .ToArray() - }); - - var netCoreFullArtifactPath = MakeAbsolute(parameters.Paths.Directories.ArtifactsBinNetCore).FullPath; - var netCoreFullArtifactPathLength = netCoreFullArtifactPath.Length+1; - - // Cake - .NET Core - NuGetPack("./nuspec/Cake.CoreCLR.nuspec", new NuGetPackSettings { - Version = parameters.Version.SemVersion, - ReleaseNotes = parameters.ReleaseNotes.Notes.ToArray(), - BasePath = netCoreFullArtifactPath, - OutputDirectory = parameters.Paths.Directories.NuGetRoot, - NoPackageAnalysis = true, - Files = GetFiles(netCoreFullArtifactPath + "/**/*") - .Select(file=>file.FullPath.Substring(netCoreFullArtifactPathLength)) - .Select(file=> new NuSpecContent { Source = file, Target = file }) - .ToArray() - }); - - DotNetCorePack("./src/Cake/Cake.csproj", new DotNetCorePackSettings { - Configuration = parameters.Configuration, - OutputDirectory = parameters.Paths.Directories.NuGetRoot, - MSBuildSettings = parameters.MSBuildSettings, - ArgumentCustomization = arg => arg.Append("/p:PackAsTool=true") - }); }); Task("Sign-Binaries") - .IsDependentOn("Zip-Files") - .IsDependentOn("Create-Chocolatey-Packages") .IsDependentOn("Create-NuGet-Packages") .WithCriteria((context, parameters) => (parameters.ShouldPublish && !parameters.SkipSigning) || @@ -378,9 +185,7 @@ Task("Sign-Binaries") var filter = File("./signclient.filter"); // Get the files to sign. - var files = GetFiles(string.Concat(parameters.Paths.Directories.NuGetRoot, "/", "*.nupkg")) - + parameters.Paths.Files.ZipArtifactPathDesktop - + parameters.Paths.Files.ZipArtifactPathCoreClr; + var files = GetFiles(string.Concat(parameters.Paths.Directories.NuGetRoot, "/", "*.nupkg")); foreach(var file in files) { @@ -410,32 +215,15 @@ Task("Sign-Binaries") Task("Upload-AppVeyor-Artifacts") .IsDependentOn("Sign-Binaries") - .IsDependentOn("Create-Chocolatey-Packages") .WithCriteria((context, parameters) => parameters.IsRunningOnAppVeyor) .Does((context, parameters) => { - AppVeyor.UploadArtifact(parameters.Paths.Files.ZipArtifactPathDesktop); - AppVeyor.UploadArtifact(parameters.Paths.Files.ZipArtifactPathCoreClr); foreach(var package in GetFiles(parameters.Paths.Directories.NuGetRoot + "/*")) { AppVeyor.UploadArtifact(package); } }); -Task("Upload-Coverage-Report") - .WithCriteria((context, parameters) => FileExists(parameters.Paths.Files.TestCoverageOutputFilePath)) - .WithCriteria((context, parameters) => !parameters.IsLocalBuild) - .WithCriteria((context, parameters) => !parameters.IsPullRequest) - .WithCriteria((context, parameters) => parameters.IsMainCakeRepo) - .IsDependentOn("Run-Unit-Tests") - .Does((context, parameters) => -{ - CoverallsIo(parameters.Paths.Files.TestCoverageOutputFilePath, new CoverallsIoSettings() - { - RepoToken = parameters.Coveralls.RepoToken - }); -}); - Task("Publish-MyGet") .IsDependentOn("Sign-Binaries") .IsDependentOn("Package") @@ -454,13 +242,15 @@ Task("Publish-MyGet") throw new InvalidOperationException("Could not resolve MyGet API url."); } - foreach(var package in parameters.Packages.All) + foreach(var package in parameters.Packages.NuGet) { // Push the package. - NuGetPush(package.PackagePath, new NuGetPushSettings { - Source = apiUrl, - ApiKey = apiKey - }); + var settings = new DotNetCoreNuGetPushSettings { + ApiKey = apiKey, + Source = apiUrl + }; + + DotNetCoreNuGetPush(package.PackagePath.FullPath, settings); } }) .OnError((exception, parameters) => @@ -490,63 +280,17 @@ Task("Publish-NuGet") foreach(var package in parameters.Packages.NuGet) { // Push the package. - NuGetPush(package.PackagePath, new NuGetPushSettings { - ApiKey = apiKey, - Source = apiUrl - }); - } -}) -.OnError((exception, parameters) => -{ - Information("Publish-NuGet Task failed, but continuing with next Task..."); - parameters.PublishingError = true; -}); - -Task("Publish-Chocolatey") - .IsDependentOn("Sign-Binaries") - .IsDependentOn("Create-Chocolatey-Packages") - .WithCriteria((context, parameters) => parameters.ShouldPublish) - .Does((context, parameters) => -{ - // Resolve the API key. - var apiKey = EnvironmentVariable("CHOCOLATEY_API_KEY"); - if(string.IsNullOrEmpty(apiKey)) { - throw new InvalidOperationException("Could not resolve Chocolatey API key."); - } + var settings = new DotNetCoreNuGetPushSettings { + ApiKey = apiKey, + Source = apiUrl + }; - // Resolve the API url. - var apiUrl = EnvironmentVariable("CHOCOLATEY_API_URL"); - if(string.IsNullOrEmpty(apiUrl)) { - throw new InvalidOperationException("Could not resolve Chocolatey API url."); - } - - foreach(var package in parameters.Packages.Chocolatey) - { - // Push the package. - ChocolateyPush(package.PackagePath, new ChocolateyPushSettings { - ApiKey = apiKey, - Source = apiUrl - }); + DotNetCoreNuGetPush(package.PackagePath.FullPath, settings); } }) .OnError((exception, parameters) => { - Information("Publish-Chocolatey Task failed, but continuing with next Task..."); - parameters.PublishingError = true; -}); - -Task("Publish-HomeBrew") - .IsDependentOn("Sign-Binaries") - .IsDependentOn("Zip-Files") - .WithCriteria((context, parameters) => parameters.ShouldPublish) - .Does((context, parameters) => -{ - var hash = CalculateFileHash(parameters.Paths.Files.ZipArtifactPathDesktop).ToHex(); - Information("Hash for creating HomeBrew PullRequest: {0}", hash); -}) -.OnError((exception, parameters) => -{ - Information("Publish-HomeBrew Task failed, but continuing with next Task..."); + Information("Publish-NuGet Task failed, but continuing with next Task..."); parameters.PublishingError = true; }); @@ -554,9 +298,6 @@ Task("Publish-GitHub-Release") .WithCriteria((context, parameters) => parameters.ShouldPublish) .Does((context, parameters) => { - GitReleaseManagerAddAssets(parameters.GitHub.Token, "cake-build", "cake", parameters.Version.Milestone, parameters.Paths.Files.ZipArtifactPathDesktop.ToString()); - GitReleaseManagerAddAssets(parameters.GitHub.Token, "cake-build", "cake", parameters.Version.Milestone, parameters.Paths.Files.ZipArtifactPathCoreClr.ToString()); - foreach(var package in GetFiles(parameters.Paths.Directories.NuGetRoot + "/*")) { GitReleaseManagerAddAssets(parameters.GitHub.Token, "cake-build", "cake", parameters.Version.Milestone, package.FullPath); @@ -587,9 +328,6 @@ Task("Prepare-Integration-Tests") { Unzip(parameters.Paths.Directories.NuGetRoot.CombineWithFilePath($"Cake.Tool.{parameters.Version.SemVersion}.nupkg"), parameters.Paths.Directories.IntegrationTestsBinTool); - - CopyDirectory(parameters.Paths.Directories.ArtifactsBinFullFx, parameters.Paths.Directories.IntegrationTestsBinFullFx); - CopyDirectory(parameters.Paths.Directories.ArtifactsBinNetCore, parameters.Paths.Directories.IntegrationTestsBinNetCore); }); Task("Frosting-Integration-Tests") @@ -616,8 +354,6 @@ Task("Frosting-Integration-Tests") ); return targetFrameworks?.Split(';') - .Where(targetFramework => context.IsRunningOnWindows() - || !targetFramework.StartsWith("net4", StringComparison.OrdinalIgnoreCase)) .Select(targetFramework => (targetFramework, project)) .ToArray(); }, @@ -654,12 +390,9 @@ Task("Run-Integration-Tests") .DeferOnError() .DoesForEach( parameters => new[] { - GetFiles($"{parameters.Paths.Directories.IntegrationTestsBinTool.FullPath}/**/netcoreapp2.1/**/Cake.dll").Single(), GetFiles($"{parameters.Paths.Directories.IntegrationTestsBinTool.FullPath}/**/netcoreapp3.1/**/Cake.dll").Single(), GetFiles($"{parameters.Paths.Directories.IntegrationTestsBinTool.FullPath}/**/net5.0/**/Cake.dll").Single(), - GetFiles($"{parameters.Paths.Directories.IntegrationTestsBinTool.FullPath}/**/net6.0/**/Cake.dll").Single(), - parameters.Paths.Directories.IntegrationTestsBinFullFx.CombineWithFilePath("Cake.exe"), - parameters.Paths.Directories.IntegrationTestsBinNetCore.CombineWithFilePath("Cake.dll") + GetFiles($"{parameters.Paths.Directories.IntegrationTestsBinTool.FullPath}/**/net6.0/**/Cake.dll").Single() }, (parameters, cakeAssembly, context) => { @@ -701,7 +434,6 @@ Task("Run-Integration-Tests") ////////////////////////////////////////////////////////////////////// Task("Package") - .IsDependentOn("Zip-Files") .IsDependentOn("Create-NuGet-Packages"); Task("Default") @@ -709,11 +441,8 @@ Task("Default") Task("AppVeyor") .IsDependentOn("Upload-AppVeyor-Artifacts") - .IsDependentOn("Upload-Coverage-Report") .IsDependentOn("Publish-MyGet") .IsDependentOn("Publish-NuGet") - .IsDependentOn("Publish-Chocolatey") - .IsDependentOn("Publish-HomeBrew") .IsDependentOn("Publish-GitHub-Release") .Does((context, parameters) => { @@ -730,7 +459,7 @@ Task("ReleaseNotes") .IsDependentOn("Create-Release-Notes"); Task("AzureDevOps") - .IsDependentOn(IsRunningOnWindows() ? "Create-Chocolatey-Packages" : "Package"); + .IsDependentOn("Package"); ////////////////////////////////////////////////////////////////////// // EXECUTION diff --git a/build/credentials.cake b/build/credentials.cake index f097c19020..3cfdb1ffe0 100644 --- a/build/credentials.cake +++ b/build/credentials.cake @@ -1,12 +1,5 @@ -public class BuildCredentials +public record BuildCredentials(string Token) { - public string Token { get; private set; } - - public BuildCredentials(string token) - { - Token = token; - } - public static BuildCredentials GetGitHubCredentials(ICakeContext context) { return new BuildCredentials( @@ -14,37 +7,13 @@ public class BuildCredentials } } -public class CoverallsCredentials +public record TwitterCredentials( + string ConsumerKey, + string ConsumerSecret, + string AccessToken, + string AccessTokenSecret +) { - public string RepoToken { get; private set; } - - public CoverallsCredentials(string repoToken) - { - RepoToken = repoToken; - } - - public static CoverallsCredentials GetCoverallsCredentials(ICakeContext context) - { - return new CoverallsCredentials( - context.EnvironmentVariable("COVERALLS_REPO_TOKEN")); - } -} - -public class TwitterCredentials -{ - public string ConsumerKey { get; private set; } - public string ConsumerSecret { get; private set; } - public string AccessToken { get; private set; } - public string AccessTokenSecret { get; private set; } - - public TwitterCredentials(string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret) - { - ConsumerKey = consumerKey; - ConsumerSecret = consumerSecret; - AccessToken = accessToken; - AccessTokenSecret = accessTokenSecret; - } - public static TwitterCredentials GetTwitterCredentials(ICakeContext context) { return new TwitterCredentials( @@ -55,17 +24,8 @@ public class TwitterCredentials } } -public class GitterCredentials +public record GitterCredentials(string Token, string RoomId) { - public string Token { get; private set; } - public string RoomId { get; private set; } - - public GitterCredentials(string token, string roomId) - { - Token = token; - RoomId = roomId; - } - public static GitterCredentials GetGitterCredentials(ICakeContext context) { return new GitterCredentials( diff --git a/build/packages.cake b/build/packages.cake index 3eba2e3703..0f5e8485f3 100644 --- a/build/packages.cake +++ b/build/packages.cake @@ -1,56 +1,30 @@ -public class BuildPackages +public record BuildPackages( + ICollection NuGet +) { - public ICollection All { get; private set; } - public ICollection NuGet { get; private set; } - public ICollection Chocolatey { get; private set; } - public static BuildPackages GetPackages( DirectoryPath nugetRooPath, string semVersion, - string[] packageIds, - string[] chocolateyPackageIds) + string[] packageIds) { var toNuGetPackage = BuildPackage(nugetRooPath, semVersion); - var toChocolateyPackage = BuildPackage(nugetRooPath, semVersion, isChocolateyPackage: true); var nugetPackages = packageIds.Select(toNuGetPackage).ToArray(); - var chocolateyPackages = chocolateyPackageIds.Select(toChocolateyPackage).ToArray(); - - return new BuildPackages { - All = nugetPackages.Union(chocolateyPackages).ToArray(), - NuGet = nugetPackages, - Chocolatey = chocolateyPackages - }; + + return new BuildPackages(nugetPackages); } private static Func BuildPackage( - DirectoryPath nugetRooPath, - string semVersion, - bool isChocolateyPackage = false) + DirectoryPath nugetRooPath, + string semVersion) { return package => new BuildPackage( - id: package, - nuspecPath: string.Concat("./nuspec/", package, ".nuspec"), - packagePath: nugetRooPath.CombineWithFilePath(string.Concat(package, ".", semVersion, ".nupkg")), - isChocolateyPackage: isChocolateyPackage); + Id: package, + PackagePath: nugetRooPath.CombineWithFilePath(string.Concat(package, ".", semVersion, ".nupkg")) + ); } } -public class BuildPackage -{ - public string Id { get; private set; } - public FilePath NuspecPath { get; private set; } - public FilePath PackagePath { get; private set; } - public bool IsChocolateyPackage { get; private set; } - - public BuildPackage( - string id, - FilePath nuspecPath, - FilePath packagePath, - bool isChocolateyPackage) - { - Id = id; - NuspecPath = nuspecPath; - PackagePath = packagePath; - IsChocolateyPackage = isChocolateyPackage; - } -} \ No newline at end of file +public record BuildPackage( + string Id, + FilePath PackagePath +); \ No newline at end of file diff --git a/build/parameters.cake b/build/parameters.cake index 5f1d598dc4..4f1dc810c7 100644 --- a/build/parameters.cake +++ b/build/parameters.cake @@ -19,10 +19,8 @@ public class BuildParameters public bool IsPublishBuild { get; } public bool IsReleaseBuild { get; } public bool SkipGitVersion { get; } - public bool SkipOpenCover { get; } public bool SkipSigning { get; } public BuildCredentials GitHub { get; } - public CoverallsCredentials Coveralls { get; } public TwitterCredentials Twitter { get; } public GitterCredentials Gitter { get; } public ReleaseNotes ReleaseNotes { get; } @@ -90,7 +88,6 @@ public class BuildParameters IsDevelopCakeBranch = StringComparer.OrdinalIgnoreCase.Equals("develop", buildSystem.AppVeyor.Environment.Repository.Branch); IsTagged = IsBuildTagged(buildSystem); GitHub = BuildCredentials.GetGitHubCredentials(context); - Coveralls = CoverallsCredentials.GetCoverallsCredentials(context); Twitter = TwitterCredentials.GetTwitterCredentials(context); Gitter = GitterCredentials.GetGitterCredentials(context); ReleaseNotes = context.ParseReleaseNotes("./ReleaseNotes.md"); @@ -98,33 +95,26 @@ public class BuildParameters IsReleaseBuild = IsReleasing(context.TargetTask.Name); SkipSigning = StringComparer.OrdinalIgnoreCase.Equals("True", context.Argument("skipsigning", "False")); SkipGitVersion = StringComparer.OrdinalIgnoreCase.Equals("True", context.EnvironmentVariable("CAKE_SKIP_GITVERSION")); - SkipOpenCover = true; //StringComparer.OrdinalIgnoreCase.Equals("True", context.EnvironmentVariable("CAKE_SKIP_OPENCOVER")); Version = BuildVersion.Calculate(context, this); Paths = BuildPaths.GetPaths(context, Configuration, Version.SemVersion); Packages = BuildPackages.GetPackages( Paths.Directories.NuGetRoot, Version.SemVersion, new [] { - "Cake", "Cake.Core", "Cake.Common", "Cake.Testing", "Cake.Testing.Xunit", - "Cake.CoreCLR", "Cake.NuGet", "Cake.Tool", "Cake.Frosting", "Cake.Frosting.Template", "Cake.Cli", "Cake.DotNetTool.Module" - }, - new [] { "cake.portable" }); + }); var releaseNotes = string.Join("\n", ReleaseNotes.Notes.ToArray()).Replace("\"", "\"\""); - MSBuildSettings = new DotNetCoreMSBuildSettings - { - WarningCodesAsMessage = { "NETSDK1138" } // EolTargetFrameworks - } + MSBuildSettings = new DotNetCoreMSBuildSettings() .WithProperty("Version", Version.SemVersion) .WithProperty("AssemblyVersion", Version.Version) .WithProperty("FileVersion", Version.Version) @@ -144,7 +134,7 @@ public class BuildParameters private static bool IsReleasing(string target) { - var targets = new [] { "Publish", "Publish-NuGet", "Publish-Chocolatey", "Publish-HomeBrew", "Publish-GitHub-Release" }; + var targets = new [] { "Publish", "Publish-NuGet", "Publish-GitHub-Release" }; return targets.Any(t => StringComparer.OrdinalIgnoreCase.Equals(t, target)); } diff --git a/build/paths.cake b/build/paths.cake index 47929285e0..bed3f9b0ec 100644 --- a/build/paths.cake +++ b/build/paths.cake @@ -1,9 +1,8 @@ -public class BuildPaths +public record BuildPaths( + BuildDirectories Directories, + FilePath SignClientPath +) { - public BuildFiles Files { get; private set; } - public BuildDirectories Directories { get; private set; } - public FilePath SignClientPath { get; private set; } - public static BuildPaths GetPaths( ICakeContext context, string configuration, @@ -24,20 +23,12 @@ public class BuildPaths } var artifactsDir = (DirectoryPath)(context.Directory("./artifacts") + context.Directory("v" + semVersion)); - var artifactsBinDir = artifactsDir.Combine("bin"); - var artifactsBinFullFx = artifactsBinDir.Combine("net461"); - var artifactsBinNetCore = artifactsBinDir.Combine("netcoreapp2.1"); var testResultsDir = artifactsDir.Combine("test-results"); var nugetRoot = artifactsDir.Combine("nuget"); - var zipArtifactPathCoreClr = artifactsDir.CombineWithFilePath("Cake-bin-coreclr-v" + semVersion + ".zip"); - var zipArtifactPathDesktop = artifactsDir.CombineWithFilePath("Cake-bin-net461-v" + semVersion + ".zip"); - var testCoverageOutputFilePath = testResultsDir.CombineWithFilePath("OpenCover.xml"); var integrationTestsBin = context.MakeAbsolute(context.Directory("./tests/integration/tools")); - var integrationTestsBinFullFx = integrationTestsBin.Combine("Cake"); - var integrationTestsBinNetCore = integrationTestsBin.Combine("Cake.CoreCLR"); var integrationTestsBinTool = integrationTestsBin.Combine("Cake.Tool"); // Directories @@ -45,94 +36,28 @@ public class BuildPaths artifactsDir, testResultsDir, nugetRoot, - artifactsBinDir, - artifactsBinFullFx, - artifactsBinNetCore, - integrationTestsBinFullFx, - integrationTestsBinNetCore, integrationTestsBinTool); - // Files - var buildFiles = new BuildFiles( - context, - zipArtifactPathCoreClr, - zipArtifactPathDesktop, - testCoverageOutputFilePath); - var signClientPath = context.Tools.Resolve("SignClient.exe") ?? context.Tools.Resolve("SignClient") ?? throw new Exception("Failed to locate sign tool"); - return new BuildPaths - { - Files = buildFiles, - Directories = buildDirectories, - SignClientPath = signClientPath - }; + return new BuildPaths( + Directories: buildDirectories, + SignClientPath: signClientPath + ); } } -public class BuildFiles -{ - public FilePath ZipArtifactPathCoreClr { get; private set; } - public FilePath ZipArtifactPathDesktop { get; private set; } - public FilePath TestCoverageOutputFilePath { get; private set; } - - public BuildFiles( - ICakeContext context, - FilePath zipArtifactPathCoreClr, - FilePath zipArtifactPathDesktop, - FilePath testCoverageOutputFilePath +public record BuildDirectories( + DirectoryPath Artifacts, + DirectoryPath TestResults, + DirectoryPath NuGetRoot, + DirectoryPath IntegrationTestsBinTool ) - { - ZipArtifactPathCoreClr = zipArtifactPathCoreClr; - ZipArtifactPathDesktop = zipArtifactPathDesktop; - TestCoverageOutputFilePath = testCoverageOutputFilePath; - } -} - -public class BuildDirectories { - public DirectoryPath Artifacts { get; } - public DirectoryPath TestResults { get; } - public DirectoryPath NuGetRoot { get; } - public DirectoryPath ArtifactsBin { get; } - public DirectoryPath ArtifactsBinFullFx { get; } - public DirectoryPath ArtifactsBinNetCore { get; } - public DirectoryPath IntegrationTestsBinFullFx { get; } - public DirectoryPath IntegrationTestsBinNetCore { get; } - public DirectoryPath IntegrationTestsBinTool { get; } - public ICollection ToClean { get; } - - public BuildDirectories( - DirectoryPath artifactsDir, - DirectoryPath testResultsDir, - DirectoryPath nugetRoot, - DirectoryPath artifactsBinDir, - DirectoryPath artifactsBinFullFx, - DirectoryPath artifactsBinNetCore, - DirectoryPath integrationTestsBinFullFx, - DirectoryPath integrationTestsBinNetCore, - DirectoryPath integrationTestsBinTool - ) - { - Artifacts = artifactsDir; - TestResults = testResultsDir; - NuGetRoot = nugetRoot; - ArtifactsBin = artifactsBinDir; - ArtifactsBinFullFx = artifactsBinFullFx; - ArtifactsBinNetCore = artifactsBinNetCore; - IntegrationTestsBinFullFx = integrationTestsBinFullFx; - IntegrationTestsBinNetCore = integrationTestsBinNetCore; - IntegrationTestsBinTool = integrationTestsBinTool; - ToClean = new[] { + public ICollection ToClean { get; } = new[] { Artifacts, TestResults, NuGetRoot, - ArtifactsBin, - ArtifactsBinFullFx, - ArtifactsBinNetCore, - IntegrationTestsBinFullFx, - IntegrationTestsBinNetCore, IntegrationTestsBinTool }; - } } \ No newline at end of file diff --git a/build/version.cake b/build/version.cake index e05eaabb2b..501579e20f 100644 --- a/build/version.cake +++ b/build/version.cake @@ -1,11 +1,11 @@ -public class BuildVersion +public record BuildVersion( + string Version, + string SemVersion, + string DotNetAsterix, + string Milestone, + string CakeVersion +) { - public string Version { get; private set; } - public string SemVersion { get; private set; } - public string DotNetAsterix { get; private set; } - public string Milestone { get; private set; } - public string CakeVersion { get; private set; } - public static BuildVersion Calculate(ICakeContext context, BuildParameters parameters) { if (context == null) @@ -74,14 +74,13 @@ public class BuildVersion var cakeVersion = typeof(ICakeContext).Assembly.GetName().Version.ToString(); - return new BuildVersion - { - Version = version, - SemVersion = semVersion, - DotNetAsterix = semVersion.Substring(version.Length).TrimStart('-'), - Milestone = milestone, - CakeVersion = cakeVersion - }; + return new BuildVersion( + Version: version, + SemVersion: semVersion, + DotNetAsterix: semVersion.Substring(version.Length).TrimStart('-'), + Milestone: milestone, + CakeVersion: cakeVersion + ); } public static string ReadSolutionInfoVersion(ICakeContext context) diff --git a/nuspec/Cake.CoreCLR.nuspec b/nuspec/Cake.CoreCLR.nuspec deleted file mode 100644 index 50ed4cbc13..0000000000 --- a/nuspec/Cake.CoreCLR.nuspec +++ /dev/null @@ -1,21 +0,0 @@ - - - - Cake.CoreCLR - 0.0.0 - Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström, Dave Glick, Pascal Berger, Jérémie Desautels, Enrico Campidoglio, C. Augusto Proiete, Nils Andresen, and contributors - The Cake script runner. - Cake (C# Make) is a build automation system with a C# DSL to do things like compiling code, copy files/folders, running unit tests, compress files and build NuGet packages. - MIT - https://cakebuild.net - cake-medium.png - https://cdn.jsdelivr.net/gh/cake-build/graphics/png/cake-medium.png - false - - Copyright (c) .NET Foundation and contributors - Cake Script Build - NuGet.org.md - - - - diff --git a/nuspec/Cake.Portable.nuspec b/nuspec/Cake.Portable.nuspec deleted file mode 100644 index 3f16005061..0000000000 --- a/nuspec/Cake.Portable.nuspec +++ /dev/null @@ -1,23 +0,0 @@ - - - - - cake.portable - Cake.Portable - 0.0.0 - Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström, Dave Glick, Pascal Berger, Jérémie Desautels, Enrico Campidoglio, C. Augusto Proiete, Nils Andresen, and contributors - Cake (C# Make) is a build automation system with a C# DSL to do things like compiling code, copy files/folders, running unit tests, compress files and build NuGet packages. - The Cake script runner. - https://cakebuild.net/ - https://github.com/cake-build/cake - https://github.com/cake-build/cake - https://cakebuild.net/docs - https://github.com/cake-build/cake/issues - Cake Script Build - Copyright (c) .NET Foundation and contributors - https://github.com/cake-build/cake/blob/develop/LICENSE - false - https://cdn.jsdelivr.net/gh/cake-build/graphics/png/cake-medium.png - - - diff --git a/nuspec/Cake.nuspec b/nuspec/Cake.nuspec deleted file mode 100644 index b23c9b84ab..0000000000 --- a/nuspec/Cake.nuspec +++ /dev/null @@ -1,21 +0,0 @@ - - - - Cake - 0.0.0 - Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström, Dave Glick, Pascal Berger, Jérémie Desautels, Enrico Campidoglio, C. Augusto Proiete, Nils Andresen, and contributors - The Cake script runner. - Cake (C# Make) is a build automation system with a C# DSL to do things like compiling code, copy files/folders, running unit tests, compress files and build NuGet packages. - MIT - https://cakebuild.net - cake-medium.png - https://cdn.jsdelivr.net/gh/cake-build/graphics/png/cake-medium.png - false - - Copyright (c) .NET Foundation and contributors - Cake Script Build - NuGet.org.md - - - - diff --git a/nuspec/VERIFICATION.txt b/nuspec/VERIFICATION.txt deleted file mode 100644 index 5db9afe09b..0000000000 --- a/nuspec/VERIFICATION.txt +++ /dev/null @@ -1,7 +0,0 @@ -VERIFICATION -Verification is intended to assist the Chocolatey moderators and community -in verifying that this package's contents are trustworthy. - -This package is published by the Cake Project itself. The binaries are -identical to other package types published by the project, in particular -the Cake nuget package. \ No newline at end of file diff --git a/src/Cake.Cli/Cake.Cli.csproj b/src/Cake.Cli/Cake.Cli.csproj index fafb69eb71..218d271b89 100644 --- a/src/Cake.Cli/Cake.Cli.csproj +++ b/src/Cake.Cli/Cake.Cli.csproj @@ -1,7 +1,6 @@  Cake.Cli - net461;netstandard2.0;net5.0;net6.0 Library AnyCpu true diff --git a/src/Cake.Common.Tests/Cake.Common.Tests.csproj b/src/Cake.Common.Tests/Cake.Common.Tests.csproj index 6c9b166a32..ac40475f6e 100644 --- a/src/Cake.Common.Tests/Cake.Common.Tests.csproj +++ b/src/Cake.Common.Tests/Cake.Common.Tests.csproj @@ -1,7 +1,6 @@  Cake.Common.Tests - net461;netcoreapp2.1;netcoreapp3.1;net5.0;net6.0 true true @@ -27,9 +26,6 @@ - - - PreserveNewest diff --git a/src/Cake.Common.Tests/Unit/XML/XmlTransformationTests.cs b/src/Cake.Common.Tests/Unit/XML/XmlTransformationTests.cs index 710991d93a..3953659f56 100644 --- a/src/Cake.Common.Tests/Unit/XML/XmlTransformationTests.cs +++ b/src/Cake.Common.Tests/Unit/XML/XmlTransformationTests.cs @@ -182,25 +182,6 @@ public void Should_Transform_Xml_String_And_Xsl_String_To_Result_String_With_Xml Assert.Equal(htm, result, ignoreLineEndingDifferences: true); } - // this feels wrong to be CLR only - [RuntimeFact(TestRuntime.Clr)] - public void Should_Transform_Xml_String_And_Xsl_String_To_Result_String_With_Utf32Xml_Declaration() - { - // Given - var xml = Resources.XmlTransformation_Xml; - var xsl = Resources.XmlTransformation_Xsl; - var settings = new XmlTransformationSettings - { - Encoding = new UTF32Encoding(false, false, true) - }; - - // When - var result = string.Concat(XmlTransformation.Transform(xsl, xml, settings).Take(39)); - - // Then - Assert.Equal("", result); - } - [Fact] public void Should_Throw_If_Xml_Was_Null() { diff --git a/src/Cake.Common/Cake.Common.csproj b/src/Cake.Common/Cake.Common.csproj index ceda48da2b..b83e2afa8c 100644 --- a/src/Cake.Common/Cake.Common.csproj +++ b/src/Cake.Common/Cake.Common.csproj @@ -1,7 +1,6 @@  Cake.Common - net461;netstandard2.0;net5.0;net6.0 Library AnyCpu true @@ -16,15 +15,4 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/src/Cake.Common/Tools/Cake/CakeRunner.cs b/src/Cake.Common/Tools/Cake/CakeRunner.cs index cc1d1d67d6..25f8192ff8 100644 --- a/src/Cake.Common/Tools/Cake/CakeRunner.cs +++ b/src/Cake.Common/Tools/Cake/CakeRunner.cs @@ -37,11 +37,7 @@ static CakeRunner() var executingAssemblyToolPath = ((FilePath)entryAssembly.Location).GetDirectory(); _executingAssemblyToolPaths = new[] { -#if NETCORE executingAssemblyToolPath.CombineWithFilePath("Cake.dll") -#else - executingAssemblyToolPath.CombineWithFilePath("Cake.exe") -#endif }; } @@ -181,17 +177,10 @@ protected override IEnumerable GetToolExecutableNames() { return new[] { -#if NETCORE "Cake.dll", "cake", "Cake", "Cake.exe" -#else - "Cake.exe", - "cake", - "Cake", - "Cake.dll" -#endif }; } diff --git a/src/Cake.Common/Xml/XmlTransformation.cs b/src/Cake.Common/Xml/XmlTransformation.cs index eaeac17c4e..1cc1d726b9 100644 --- a/src/Cake.Common/Xml/XmlTransformation.cs +++ b/src/Cake.Common/Xml/XmlTransformation.cs @@ -10,10 +10,6 @@ using Cake.Core; using Cake.Core.IO; -#if !NETCORE - -#endif - namespace Cake.Common.Xml { /// diff --git a/src/Cake.Core.Tests/Cake.Core.Tests.csproj b/src/Cake.Core.Tests/Cake.Core.Tests.csproj index c211871345..5af6e0dcc0 100644 --- a/src/Cake.Core.Tests/Cake.Core.Tests.csproj +++ b/src/Cake.Core.Tests/Cake.Core.Tests.csproj @@ -1,7 +1,6 @@  Cake.Core.Tests - net461;netcoreapp2.1;netcoreapp3.1;net5.0;net6.0 true true diff --git a/src/Cake.Core.Tests/Unit/CakeRuntimeTests.cs b/src/Cake.Core.Tests/Unit/CakeRuntimeTests.cs index 53e408568a..21aad8bf1e 100644 --- a/src/Cake.Core.Tests/Unit/CakeRuntimeTests.cs +++ b/src/Cake.Core.Tests/Unit/CakeRuntimeTests.cs @@ -24,7 +24,6 @@ public TheBuiltFrameworkProperty(ITestOutputHelper testOutputHelper) TestOutputHelper = testOutputHelper; } - [RuntimeFact(TestRuntime.CoreClr)] public void Should_Return_Correct_Result_For_CoreClr() { // Given @@ -138,21 +137,5 @@ public void Should_Return_Correct_Result_For_CoreClr() #endif } } - - public sealed class TheExecutingFrameworkProperty - { - [RuntimeFact(TestRuntime.Clr)] - public void Should_Return_Correct_Result_For_Clr() - { - // Given - var runtime = new CakeRuntime(); - - // When - var framework = runtime.BuiltFramework; - - // Then - Assert.Equal(".NETFramework,Version=v4.6.1", framework.FullName); - } - } } } diff --git a/src/Cake.Core.Tests/Unit/IO/ProcessRunnerTests.cs b/src/Cake.Core.Tests/Unit/IO/ProcessRunnerTests.cs index 25bc12d43b..500d6d6ac8 100644 --- a/src/Cake.Core.Tests/Unit/IO/ProcessRunnerTests.cs +++ b/src/Cake.Core.Tests/Unit/IO/ProcessRunnerTests.cs @@ -163,7 +163,6 @@ public void Should_Not_Log_Secret_Arguments() .Verbose(Verbosity.Diagnostic, "Executing: {0}", "\"/Program Files/Cake.exe\" [REDACTED]"); } - [RuntimeFact(TestRuntime.CoreClr)] public void Should_Coerse_Mono_On_Unix_And_CoreClr() { // Given @@ -181,7 +180,6 @@ public void Should_Coerse_Mono_On_Unix_And_CoreClr() .Write(Verbosity.Diagnostic, LogLevel.Verbose, "{0} is a .NET Framework executable, will try execute using Mono.", "/Program Files/Cake.exe"); } - [RuntimeFact(TestRuntime.CoreClr)] public void Should_Not_Coerse_Mono_On_Windows_And_CoreClr() { // Given @@ -195,7 +193,6 @@ public void Should_Not_Coerse_Mono_On_Windows_And_CoreClr() Assert.Equal("\"/Program Files/Cake.exe\"", result.FileName); } - [RuntimeFact(TestRuntime.CoreClr)] public void Should_Not_Coerse_Mono_On_Unix_And_CoreClr_With_Config_NoMonoCoersion() { // Given @@ -210,7 +207,6 @@ public void Should_Not_Coerse_Mono_On_Unix_And_CoreClr_With_Config_NoMonoCoersio Assert.Equal("/Program Files/Cake.exe", result.FileName); } - [RuntimeFact(TestRuntime.CoreClr)] public void Should_Not_Coerse_Mono_On_Unix_And_CoreClr_If_Mono_Not_Resolved() { // Given diff --git a/src/Cake.Core.Tests/Unit/Scripting/ScriptRunnerTests.cs b/src/Cake.Core.Tests/Unit/Scripting/ScriptRunnerTests.cs index 3e4bfa700c..6918745332 100644 --- a/src/Cake.Core.Tests/Unit/Scripting/ScriptRunnerTests.cs +++ b/src/Cake.Core.Tests/Unit/Scripting/ScriptRunnerTests.cs @@ -165,29 +165,6 @@ public void Should_Set_Working_Directory_To_Script_Directory() Assert.Equal("/build", fixture.Environment.WorkingDirectory.FullPath); } -#if !NETCORE - [Theory] - [InlineData("mscorlib")] - [InlineData("System")] - [InlineData("System.Core")] - [InlineData("System.Data")] - [InlineData("System.Xml")] - [InlineData("System.Xml.Linq")] - public void Should_Add_References_To_Session(string assemblyName) - { - // Given - var fixture = new ScriptRunnerFixture(); - var runner = fixture.CreateScriptRunner(); - - // When - runner.Run(fixture.Host, fixture.Script); - - // Then - fixture.Session.Received(1).AddReference( - Arg.Is(a => a.FullName.StartsWith(assemblyName + ", ", StringComparison.OrdinalIgnoreCase))); - } -#endif - [Theory] [InlineData("System")] [InlineData("System.Collections.Generic")] diff --git a/src/Cake.Core/Cake.Core.csproj b/src/Cake.Core/Cake.Core.csproj index 6e1c072d7f..a3f0dc4585 100644 --- a/src/Cake.Core/Cake.Core.csproj +++ b/src/Cake.Core/Cake.Core.csproj @@ -1,7 +1,6 @@  Cake.Core - net461;netstandard2.0;net5.0;net6.0 Library AnyCpu true @@ -12,17 +11,9 @@ - - + + - - - - - - - - \ No newline at end of file diff --git a/src/Cake.Core/CakeException.cs b/src/Cake.Core/CakeException.cs index c2b8461db9..62c59b199e 100644 --- a/src/Cake.Core/CakeException.cs +++ b/src/Cake.Core/CakeException.cs @@ -3,18 +3,12 @@ // See the LICENSE file in the project root for more information. using System; -#if !NETCORE -using System.Runtime.Serialization; -#endif namespace Cake.Core { /// /// Represent errors that occur during script execution. /// -#if !NETCORE - [Serializable] -#endif public sealed class CakeException : Exception { /// @@ -79,17 +73,5 @@ public CakeException(int exitCode, string message, Exception innerException) { ExitCode = exitCode; } - -#if !NETCORE - /// - /// Initializes a new instance of the class. - /// - /// The that holds the serialized object data about the exception being thrown. - /// The that contains contextual information about the source or destination. - private CakeException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } -#endif } } \ No newline at end of file diff --git a/src/Cake.Core/IO/ProcessRunner.cs b/src/Cake.Core/IO/ProcessRunner.cs index 86e31ac6cb..9cd8113bf1 100644 --- a/src/Cake.Core/IO/ProcessRunner.cs +++ b/src/Cake.Core/IO/ProcessRunner.cs @@ -101,7 +101,6 @@ internal ProcessStartInfo GetProcessStartInfo(FilePath filePath, ProcessSettings var arguments = settings.Arguments ?? new ProcessArgumentBuilder(); filterUnsafe = arguments.FilterUnsafe; -#if NETCORE if (!_noMonoCoersion && _environment.Platform.IsUnix() && _environment.Runtime.IsCoreClr && @@ -126,7 +125,6 @@ internal ProcessStartInfo GetProcessStartInfo(FilePath filePath, ProcessSettings } } } -#endif if (!settings.Silent) { diff --git a/src/Cake.Core/Polyfill/AssemblyHelper.cs b/src/Cake.Core/Polyfill/AssemblyHelper.cs index 22cc11be4f..f2b4615181 100644 --- a/src/Cake.Core/Polyfill/AssemblyHelper.cs +++ b/src/Cake.Core/Polyfill/AssemblyHelper.cs @@ -6,9 +6,7 @@ using System.Reflection; using System.Runtime.InteropServices; using Cake.Core.IO; -#if NETCORE using Cake.Core.Reflection; -#endif namespace Cake.Core.Polyfill { diff --git a/src/Cake.Core/Polyfill/EnvironmentHelper.cs b/src/Cake.Core/Polyfill/EnvironmentHelper.cs index f9e38a0eb6..465b05ed01 100644 --- a/src/Cake.Core/Polyfill/EnvironmentHelper.cs +++ b/src/Cake.Core/Polyfill/EnvironmentHelper.cs @@ -3,38 +3,27 @@ // See the LICENSE file in the project root for more information. using System; -#if NETCORE using System.Linq; using System.Reflection; using System.Runtime.InteropServices; -#endif using System.Runtime.Versioning; namespace Cake.Core.Polyfill { internal static class EnvironmentHelper { -#if !NETCORE - private static bool? _isRunningOnMac; -#else private static readonly FrameworkName NetStandardFramework = new FrameworkName(".NETStandard,Version=v2.0"); private static bool? _isCoreClr; private static FrameworkName netCoreAppFramwork; -#endif public static bool Is64BitOperativeSystem() { -#if NETCORE return RuntimeInformation.OSArchitecture == Architecture.X64 || RuntimeInformation.OSArchitecture == Architecture.Arm64; -#else - return Environment.Is64BitOperatingSystem; -#endif } public static PlatformFamily GetPlatformFamily() { -#if NETCORE try { if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) @@ -65,40 +54,18 @@ public static PlatformFamily GetPlatformFamily() catch (PlatformNotSupportedException) { } -#else - var platform = (int)Environment.OSVersion.Platform; - if (platform <= 3 || platform == 5) - { - return PlatformFamily.Windows; - } - if (!_isRunningOnMac.HasValue) - { - _isRunningOnMac = Native.MacOSX.IsRunningOnMac(); - } - if (_isRunningOnMac ?? false || platform == (int)PlatformID.MacOSX) - { - return PlatformFamily.OSX; - } - if (platform == 4 || platform == 6 || platform == 128) - { - return PlatformFamily.Linux; - } -#endif + return PlatformFamily.Unknown; } public static bool IsCoreClr() { -#if NETCORE if (_isCoreClr == null) { _isCoreClr = Environment.Version.Major >= 5 || RuntimeInformation.FrameworkDescription.StartsWith(".NET Core"); } return _isCoreClr.Value; -#else - return false; -#endif } public static bool IsWindows(PlatformFamily family) @@ -138,7 +105,6 @@ public static Runtime GetRuntime() public static FrameworkName GetBuiltFramework() { -#if NETCORE if (netCoreAppFramwork != null) { return netCoreAppFramwork; @@ -146,11 +112,11 @@ public static FrameworkName GetBuiltFramework() var assemblyPath = typeof(System.Runtime.GCSettings)?.GetTypeInfo() ?.Assembly -#if NET5_0_OR_GREATER - ?.Location; +#if NETCOREAPP3_1 + ?.CodeBase; #else #pragma warning disable 0618 - ?.CodeBase; + ?.Location; #pragma warning restore 0618 #endif if (string.IsNullOrEmpty(assemblyPath)) @@ -169,9 +135,6 @@ public static FrameworkName GetBuiltFramework() return netCoreAppFramwork = Version.TryParse(netCoreAppVersion, out var version) ? new FrameworkName(".NETCoreApp", version) : NetStandardFramework; -#else - return new FrameworkName(".NETFramework,Version=v4.6.1"); -#endif } } } \ No newline at end of file diff --git a/src/Cake.Core/Polyfill/MacOSXNative.cs b/src/Cake.Core/Polyfill/MacOSXNative.cs deleted file mode 100644 index 061c4b8746..0000000000 --- a/src/Cake.Core/Polyfill/MacOSXNative.cs +++ /dev/null @@ -1,62 +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. - -///////////////////////////////////////////////////////////////////////////////////////////////////// -// This code was taken and adapted from the MonoDevelop project. -// https://github.com/mono/monodevelop/blob/master/main/src/core/Mono.Texteditor/Mono.TextEditor/Platform.cs -// Copyright (c) 2009 Novell, Inc. (http://www.novell.com) -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -///////////////////////////////////////////////////////////////////////////////////////////////////// - -#if !NETCORE -using System; -using System.Runtime.InteropServices; -using System.Text; -using Cake.Core.IO; - -namespace Cake.Core.Polyfill -{ - internal static partial class Native - { - public static class MacOSX - { - [DllImport("libc")] - internal static extern int uname(IntPtr buf); - - public static bool IsRunningOnMac() - { - try - { - IntPtr buf = IntPtr.Zero; - try - { - buf = Marshal.AllocHGlobal(8192); - if (uname(buf) == 0) - { - string os = Marshal.PtrToStringAnsi(buf); - if (os == "Darwin") - { - return true; - } - } - } - finally - { - if (buf != IntPtr.Zero) - { - Marshal.FreeHGlobal(buf); - } - } - } - catch - { - // Ignore any other possible failures on non-OSX platforms - } - - return false; - } - } - } -} -#endif \ No newline at end of file diff --git a/src/Cake.Core/Polyfill/ProcessHelper.cs b/src/Cake.Core/Polyfill/ProcessHelper.cs index 06006b1215..ee57a4700e 100644 --- a/src/Cake.Core/Polyfill/ProcessHelper.cs +++ b/src/Cake.Core/Polyfill/ProcessHelper.cs @@ -12,13 +12,8 @@ internal static class ProcessHelper { public static void SetEnvironmentVariable(ProcessStartInfo info, string key, string value) { -#if NETCORE - var envKey = info.Environment.Keys.FirstOrDefault(exisitingKey => StringComparer.OrdinalIgnoreCase.Equals(exisitingKey, key)) ?? key; + var envKey = info.Environment.Keys.FirstOrDefault(existingKey => StringComparer.OrdinalIgnoreCase.Equals(existingKey, key)) ?? key; info.Environment[envKey] = value; -#else - var envKey = info.EnvironmentVariables.Keys.Cast().FirstOrDefault(existingKey => StringComparer.OrdinalIgnoreCase.Equals(existingKey, key)) ?? key; - info.EnvironmentVariables[envKey] = value; -#endif } } } diff --git a/src/Cake.Core/Polyfill/SpecialPathHelper.cs b/src/Cake.Core/Polyfill/SpecialPathHelper.cs index ccd384f68a..208e6a9920 100644 --- a/src/Cake.Core/Polyfill/SpecialPathHelper.cs +++ b/src/Cake.Core/Polyfill/SpecialPathHelper.cs @@ -17,34 +17,16 @@ public static DirectoryPath GetFolderPath(ICakePlatform platform, SpecialPath pa return new DirectoryPath(System.IO.Path.GetTempPath()); } -#if NETCORE var result = GetXPlatFolderPath(platform, path); if (result != null) { return new DirectoryPath(result); } -#else - switch (path) - { - case SpecialPath.ApplicationData: - return new DirectoryPath(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); - case SpecialPath.CommonApplicationData: - return new DirectoryPath(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)); - case SpecialPath.LocalApplicationData: - return new DirectoryPath(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)); - case SpecialPath.ProgramFiles: - return new DirectoryPath(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)); - case SpecialPath.ProgramFilesX86: - return new DirectoryPath(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)); - case SpecialPath.Windows: - return new DirectoryPath(Environment.GetFolderPath(Environment.SpecialFolder.Windows)); - } -#endif + const string format = "The special path '{0}' is not supported."; throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, format, path)); } -#if NETCORE private static string GetXPlatFolderPath(ICakePlatform platform, SpecialPath path) { if (platform.IsUnix()) @@ -57,6 +39,5 @@ private static string GetXPlatFolderPath(ICakePlatform platform, SpecialPath pat } throw new PlatformNotSupportedException(); } -#endif } } diff --git a/src/Cake.Core/Polyfill/UnixNative.cs b/src/Cake.Core/Polyfill/UnixNative.cs index 269a1a1885..8559c132af 100644 --- a/src/Cake.Core/Polyfill/UnixNative.cs +++ b/src/Cake.Core/Polyfill/UnixNative.cs @@ -9,7 +9,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. ///////////////////////////////////////////////////////////////////////////////////////////////////// -#if NETCORE using System; using System.Runtime.InteropServices; using System.Text; @@ -59,5 +58,4 @@ public static string GetFolder(SpecialPath folder) } } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Cake.Core/Polyfill/WindowsNative.cs b/src/Cake.Core/Polyfill/WindowsNative.cs index 1c8f101b9e..c95f90920a 100644 --- a/src/Cake.Core/Polyfill/WindowsNative.cs +++ b/src/Cake.Core/Polyfill/WindowsNative.cs @@ -9,7 +9,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. ///////////////////////////////////////////////////////////////////////////////////////////////////// -#if NETCORE using System; using System.Collections.Generic; using System.Runtime.InteropServices; @@ -57,5 +56,4 @@ public static string GetFolder(SpecialPath folder) } } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Cake.Core/Scripting/ScriptAliasFinder.cs b/src/Cake.Core/Scripting/ScriptAliasFinder.cs index b459e96ca9..ee06b30702 100644 --- a/src/Cake.Core/Scripting/ScriptAliasFinder.cs +++ b/src/Cake.Core/Scripting/ScriptAliasFinder.cs @@ -67,13 +67,6 @@ public IReadOnlyList FindAliases(IEnumerable assemblies) { notFound.Add(fileNotFoundException.FileName); } -#if !NETCORE - if (!string.IsNullOrEmpty(fileNotFoundException.FusionLog)) - { - _log.Debug("Fusion Log:"); - _log.Debug(fileNotFoundException.FusionLog); - } -#endif } _log.Debug(string.Empty); } diff --git a/src/Cake.Core/Scripting/ScriptConventions.cs b/src/Cake.Core/Scripting/ScriptConventions.cs index 5d5aeaffc8..979ca37296 100644 --- a/src/Cake.Core/Scripting/ScriptConventions.cs +++ b/src/Cake.Core/Scripting/ScriptConventions.cs @@ -65,7 +65,6 @@ public IReadOnlyList GetDefaultAssemblies(DirectoryPath root) var cakeAssemblies = LoadCakeAssemblies(root); result.AddRange(cakeAssemblies); -#if NETCORE // Load all referenced assemblies. foreach (var cakeAssembly in cakeAssemblies) { @@ -74,30 +73,6 @@ public IReadOnlyList GetDefaultAssemblies(DirectoryPath root) result.Add(_loader.Load(reference)); } } -#else - result.Add(typeof(Uri).GetTypeInfo().Assembly); // System - result.Add(typeof(System.Xml.XmlReader).GetTypeInfo().Assembly); // System.Xml - result.Add(typeof(System.Xml.Linq.XDocument).GetTypeInfo().Assembly); // System.Xml.Linq - result.Add(typeof(System.Data.DataTable).GetTypeInfo().Assembly); // System.Data - - // This is just to please Roslyn when running under Mono. See issue https://github.com/dotnet/roslyn/issues/19364 - result.Add(_loader.Load(new AssemblyName("System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"))); // System.Runtime - result.Add(_loader.Load(new AssemblyName("System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"))); // System.Collections - result.Add(_loader.Load(new AssemblyName("System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"))); // System.Net.Http - - try - { - result.Add(_loader.Load(new AssemblyName("netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"))); // NETStandard.Library - } - catch - { - /* - * Silently continue instead and let it blow up during runtime if netstandard assembly was not found. - * TODO: Log that netstandard assembly was not found. - * Unfortunately, logger is not available in this class, and that would be too big of a change for the 0.26.1 hotfix release. - */ - } -#endif // Return the assemblies. return result.ToArray(); @@ -167,12 +142,6 @@ private List LoadCakeAssemblies(DirectoryPath root) // ReSharper disable once ReturnTypeCanBeEnumerable.Local private static string[] GetCakeAssemblyNames() - { -#if NETCORE - return new[] { "Cake.Core.dll", "Cake.Common.dll", "Spectre.Console.dll" }; -#else - return new[] { "Cake.Core.dll", "Cake.Common.dll", "Cake.exe", "Spectre.Console.dll" }; -#endif - } + => new[] { "Cake.Core.dll", "Cake.Common.dll", "Spectre.Console.dll" }; } } \ No newline at end of file diff --git a/src/Cake.DotNetTool.Module.Tests/Cake.DotNetTool.Module.Tests.csproj b/src/Cake.DotNetTool.Module.Tests/Cake.DotNetTool.Module.Tests.csproj index 4775dc38d0..1b00f815ad 100644 --- a/src/Cake.DotNetTool.Module.Tests/Cake.DotNetTool.Module.Tests.csproj +++ b/src/Cake.DotNetTool.Module.Tests/Cake.DotNetTool.Module.Tests.csproj @@ -2,7 +2,6 @@ Cake.DotNetTool.Module.Tests - net461;netcoreapp2.1;netcoreapp3.1;net5.0;net6.0 true true diff --git a/src/Cake.DotNetTool.Module/Cake.DotNetTool.Module.csproj b/src/Cake.DotNetTool.Module/Cake.DotNetTool.Module.csproj index 533a410c72..de8e466f32 100644 --- a/src/Cake.DotNetTool.Module/Cake.DotNetTool.Module.csproj +++ b/src/Cake.DotNetTool.Module/Cake.DotNetTool.Module.csproj @@ -1,7 +1,6 @@  Cake.DotNetTool.Module - net461;netstandard2.0;net5.0;net6.0 true true snupkg @@ -19,8 +18,8 @@ - - diff --git a/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj b/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj index 3e8025e351..4b51d8586c 100644 --- a/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj +++ b/src/Cake.Frosting.Example/Cake.Frosting.Example.csproj @@ -1,6 +1,5 @@  - net461;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0;net5.0;net6.0 Cake.Frosting.Example Exe true diff --git a/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj b/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj index 275666e16f..f55a0ec415 100644 --- a/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj +++ b/src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj @@ -1,9 +1,5 @@ - - net461;netcoreapp2.1;netcoreapp3.0;net5.0;net6.0 - - @@ -23,14 +19,6 @@ - - - - - - - - diff --git a/src/Cake.Frosting/Cake.Frosting.csproj b/src/Cake.Frosting/Cake.Frosting.csproj index e5f1d26dff..2055e3edba 100644 --- a/src/Cake.Frosting/Cake.Frosting.csproj +++ b/src/Cake.Frosting/Cake.Frosting.csproj @@ -1,7 +1,6 @@  The .NET Core host for Cake. - net461;netstandard2.0;net5.0;net6.0 true Cake.Frosting diff --git a/src/Cake.NuGet.Tests/Cake.NuGet.Tests.csproj b/src/Cake.NuGet.Tests/Cake.NuGet.Tests.csproj index 2e4782d46d..343d59d37c 100644 --- a/src/Cake.NuGet.Tests/Cake.NuGet.Tests.csproj +++ b/src/Cake.NuGet.Tests/Cake.NuGet.Tests.csproj @@ -1,7 +1,6 @@  Cake.NuGet.Tests - net461;netcoreapp2.1;netcoreapp3.1;net5.0;net6.0 true true @@ -25,12 +24,6 @@ - - - - - - diff --git a/src/Cake.NuGet.Tests/Unit/NuGetContentResolverTests.cs b/src/Cake.NuGet.Tests/Unit/NuGetContentResolverTests.cs index 75810d7d25..295591712b 100644 --- a/src/Cake.NuGet.Tests/Unit/NuGetContentResolverTests.cs +++ b/src/Cake.NuGet.Tests/Unit/NuGetContentResolverTests.cs @@ -333,7 +333,6 @@ public void Should_Not_Return_Ref_Assemblies(string framework, Runtime runtime) Assert.Equal(0, result.Count); } - [RuntimeFact(TestRuntime.CoreClr)] public void Should_Return_Runtimes_Assemblies_If_CoreCLR() { // Given @@ -353,7 +352,6 @@ public void Should_Return_Runtimes_Assemblies_If_CoreCLR() Assert.Equal(1, result.Count); } - [RuntimeFact(TestRuntime.CoreClr)] public void Should_Return_Native_Runtimes_Assemblies_If_CoreCLR() { // Given @@ -371,26 +369,6 @@ public void Should_Return_Native_Runtimes_Assemblies_If_CoreCLR() // Then Assert.Equal(1, result.Count); } - - [RuntimeFact(TestRuntime.Clr)] - public void Should_Not_Return_Runtimes_Assemblies_If_Clr() - { - // Given - var framework = ".NETFramework,Version=v4.6.1"; - var runtime = Runtime.Clr; - var fixture = new NuGetAddinContentResolverFixture(framework, runtime); - - fixture.CreateCLRAssembly("/Working/runtimes/win/lib/netstandard1.6/file.dll"); - fixture.CreateCLRAssembly("/Working/runtimes/unix/lib/netstandard1.6/file.dll"); - fixture.FileSystem.CreateFile("/Working/lib/netstandard1.6/_._"); - fixture.FileSystem.CreateFile("/Working/lib/net46/_._"); - - // When - var result = fixture.GetFiles(); - - // Then - Assert.Equal(0, result.Count); - } } } } \ No newline at end of file diff --git a/src/Cake.NuGet.Tests/Unit/NuGetModuleTests.cs b/src/Cake.NuGet.Tests/Unit/NuGetModuleTests.cs index 32e945d623..d86667898e 100644 --- a/src/Cake.NuGet.Tests/Unit/NuGetModuleTests.cs +++ b/src/Cake.NuGet.Tests/Unit/NuGetModuleTests.cs @@ -32,7 +32,6 @@ public void Should_Register_The_NuGet_Content_Resolver() fixture.Builder.Received(1).Singleton(); } - [RuntimeFact(TestRuntime.Clr)] public void Should_Register_The_NuGet_Load_Directive_Provider() { // Given @@ -48,22 +47,6 @@ public void Should_Register_The_NuGet_Load_Directive_Provider() fixture.Builder.Received(1).Singleton(); } - [RuntimeFact(TestRuntime.CoreClr)] - public void Should_Register_The_NuGet_Load_Directive_Provider_When_Using_In_Process_Client() - { - // Given - var fixture = new NuGetModuleFixture(); - var module = fixture.CreateModule(); - - // When - module.Register(fixture.Registrar); - - // Then - fixture.Registrar.Received(1).RegisterType(); - fixture.Builder.Received(1).As(); - fixture.Builder.Received(1).Singleton(); - } - [Fact] public void Should_Register_The_NuGet_Package_Installer() { diff --git a/src/Cake.NuGet/Cake.NuGet.csproj b/src/Cake.NuGet/Cake.NuGet.csproj index 5775402f99..6ffae5f178 100644 --- a/src/Cake.NuGet/Cake.NuGet.csproj +++ b/src/Cake.NuGet/Cake.NuGet.csproj @@ -1,7 +1,6 @@  Cake.NuGet - net461;netstandard2.0;net5.0;net6.0 Library AnyCpu true diff --git a/src/Cake.NuGet/Installers/OutOfProcessInstaller.cs b/src/Cake.NuGet/Installers/OutOfProcessInstaller.cs index 86140d5a6a..478dfbafa2 100644 --- a/src/Cake.NuGet/Installers/OutOfProcessInstaller.cs +++ b/src/Cake.NuGet/Installers/OutOfProcessInstaller.cs @@ -11,12 +11,7 @@ using Cake.Core.IO; using Cake.Core.IO.NuGet; using Cake.Core.Packaging; - -#if NETCORE using NuGet.Versioning; -#else -using NuGet; -#endif using IFileSystem = Cake.Core.IO.IFileSystem; using PackageReference = Cake.Core.Packaging.PackageReference; diff --git a/src/Cake.NuGet/NuGetContentResolver.cs b/src/Cake.NuGet/NuGetContentResolver.cs index 2373578a88..631897c6e6 100644 --- a/src/Cake.NuGet/NuGetContentResolver.cs +++ b/src/Cake.NuGet/NuGetContentResolver.cs @@ -25,15 +25,11 @@ internal sealed class NuGetContentResolver : INuGetContentResolver private static readonly Lazy RuntimeGraph = new Lazy(() => { -#if NETCORE var assembly = typeof(NuGetContentResolver).Assembly; using (var stream = assembly.GetManifestResourceStream($"{assembly.GetName().Name}.runtime.json")) { return JsonRuntimeFormat.ReadRuntimeGraph(stream); } -#else - return global::NuGet.RuntimeModel.RuntimeGraph.Empty; -#endif }); public NuGetContentResolver( diff --git a/src/Cake.Testing.Xunit/Cake.Testing.Xunit.csproj b/src/Cake.Testing.Xunit/Cake.Testing.Xunit.csproj index 907d895221..b5c57f8455 100644 --- a/src/Cake.Testing.Xunit/Cake.Testing.Xunit.csproj +++ b/src/Cake.Testing.Xunit/Cake.Testing.Xunit.csproj @@ -1,7 +1,6 @@  Cake.Testing.Xunit - net461;netstandard2.0;net5.0;net6.0 Library AnyCpu true diff --git a/src/Cake.Testing.Xunit/RuntimeFact.cs b/src/Cake.Testing.Xunit/RuntimeFact.cs deleted file mode 100644 index 17b0502d9e..0000000000 --- a/src/Cake.Testing.Xunit/RuntimeFact.cs +++ /dev/null @@ -1,26 +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.Core.Polyfill; -using Xunit; - -namespace Cake.Testing.Xunit -{ - public sealed class RuntimeFact : FactAttribute - { - public RuntimeFact(TestRuntime runtime) - { - if (runtime.HasFlag(TestRuntime.Clr) - && EnvironmentHelper.GetRuntime() != Runtime.Clr) - { - Skip = "Full framework test."; - } - else if (runtime.HasFlag(TestRuntime.CoreClr) - && EnvironmentHelper.GetRuntime() != Runtime.CoreClr) - { - Skip = ".NET Core test."; - } - } - } -} diff --git a/src/Cake.Testing.Xunit/RuntimeTheory.cs b/src/Cake.Testing.Xunit/RuntimeTheory.cs deleted file mode 100644 index 74a7748ff8..0000000000 --- a/src/Cake.Testing.Xunit/RuntimeTheory.cs +++ /dev/null @@ -1,27 +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 Xunit; - -namespace Cake.Testing.Xunit -{ - public sealed class RuntimeTheory : TheoryAttribute - { - public RuntimeTheory(TestRuntime runtime) - { - if (runtime.HasFlag(TestRuntime.Clr)) - { -#if NETCORE - Skip = "Full framework test."; -#endif - } - else if (runtime.HasFlag(TestRuntime.CoreClr)) - { -#if !NETCORE - Skip = ".NET Core test."; -#endif - } - } - } -} \ No newline at end of file diff --git a/src/Cake.Testing/Cake.Testing.csproj b/src/Cake.Testing/Cake.Testing.csproj index d54a9f76cb..2ad9a7d09c 100644 --- a/src/Cake.Testing/Cake.Testing.csproj +++ b/src/Cake.Testing/Cake.Testing.csproj @@ -1,7 +1,6 @@  Cake.Testing - net461;netstandard2.0;net5.0;net6.0 Library AnyCpu true diff --git a/src/Cake.Testing/Extensions/FakeFileExtensions.cs b/src/Cake.Testing/Extensions/FakeFileExtensions.cs index 215746ba17..f1ec537676 100644 --- a/src/Cake.Testing/Extensions/FakeFileExtensions.cs +++ b/src/Cake.Testing/Extensions/FakeFileExtensions.cs @@ -38,10 +38,6 @@ public static FakeFile SetContent(this FakeFile file, string content) { writer.Write(content); file.LastWriteTime = DateTime.Now; -#if !NETCORE - writer.Close(); - stream.Close(); -#endif return file; } } diff --git a/src/Cake.Tests/Cake.Tests.csproj b/src/Cake.Tests/Cake.Tests.csproj index 48a96d37b7..cfbf864528 100644 --- a/src/Cake.Tests/Cake.Tests.csproj +++ b/src/Cake.Tests/Cake.Tests.csproj @@ -2,7 +2,6 @@ Cake.Tests - net461;netcoreapp2.1;netcoreapp3.1;net5.0;net6.0 true true @@ -20,12 +19,7 @@ - - - - - - + diff --git a/src/Cake/Cake.csproj b/src/Cake/Cake.csproj index 568829c2fc..8599c4c8d0 100644 --- a/src/Cake/Cake.csproj +++ b/src/Cake/Cake.csproj @@ -4,16 +4,12 @@ Cake Exe AnyCpu - netcoreapp2.1;netcoreapp3.1;net5.0;net6.0 - - - - net461;$(TargetFrameworks); - + + true Cake.Tool dotnet-cake The Cake .NET Tool. diff --git a/src/Cake/Infrastructure/Scripting/RoslynScriptSession.cs b/src/Cake/Infrastructure/Scripting/RoslynScriptSession.cs index 4c223e70da..a610344540 100644 --- a/src/Cake/Infrastructure/Scripting/RoslynScriptSession.cs +++ b/src/Cake/Infrastructure/Scripting/RoslynScriptSession.cs @@ -68,11 +68,7 @@ public void AddReference(FilePath path) } _log.Debug("Adding reference to {0}...", path.GetFilename().FullPath); -#if NETCORE References.Add(_loader.Load(path, true)); -#else - ReferencePaths.Add(path); -#endif } public void ImportNamespace(string @namespace) diff --git a/src/Cake/Program.cs b/src/Cake/Program.cs index e52fd88a89..c0ef00e958 100644 --- a/src/Cake/Program.cs +++ b/src/Cake/Program.cs @@ -46,16 +46,7 @@ public async Task Run(string[] args) #pragma warning disable SA1114 // Parameter list should follow declaration #pragma warning disable SA1009 // Closing parenthesis should be spaced correctly #pragma warning disable SA1111 // Closing parenthesis should be on line of last parameter - config.SetApplicationName( -#if NETCOREAPP2_0 - - "dotnet Cake.dll" -#elif NETFRAMEWORK - "Cake.exe" -#else - "dotnet cake" -#endif - ); + config.SetApplicationName("dotnet cake"); #pragma warning restore SA1111 // Closing parenthesis should be on line of last parameter #pragma warning restore SA1009 // Closing parenthesis should be spaced correctly #pragma warning restore SA1114 // Parameter list should follow declaration diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 0febdca945..fdf4321afe 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,6 +1,4 @@ - - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb true diff --git a/src/Shared.msbuild b/src/Shared.msbuild index f77a1a14bf..3e654f3d3e 100644 --- a/src/Shared.msbuild +++ b/src/Shared.msbuild @@ -1,6 +1,7 @@ + netcoreapp3.1;net5.0;net6.0 $(AssemblyName) Copyright (c) .NET Foundation and contributors Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström, Dave Glick, Pascal Berger, Jérémie Desautels, Enrico Campidoglio, C. Augusto Proiete, Nils Andresen, and contributors @@ -16,7 +17,7 @@ - + 2.0.0 $(DefineConstants);NETCORE portable diff --git a/tests/integration/Cake.Common/ArgumentAliases.cake b/tests/integration/Cake.Common/ArgumentAliases.cake index 68db3d32bc..5b5a2ce83a 100644 --- a/tests/integration/Cake.Common/ArgumentAliases.cake +++ b/tests/integration/Cake.Common/ArgumentAliases.cake @@ -7,7 +7,7 @@ Task("Cake.Common.ArgumentAliases.HasArgument") { // Given, When var arg = HasArgument("customarg"); - + // Then Assert.True(arg); }); @@ -17,7 +17,7 @@ Task("Cake.Common.ArgumentAliases.HasArgument.ThatDoNotExist") { // Given, When var arg = HasArgument("nonexisting"); - + // Then Assert.False(arg); }); @@ -45,7 +45,7 @@ Task("Cake.Common.ArgumentAliases.Argument.WithDefaultValue") Task("Cake.Common.ArgumentAliases.Argument.MultipleArguments") .Does(() => { - + // Given, When var arg = Arguments("multipleargs"); @@ -70,13 +70,7 @@ Task("Cake.Common.ArgumentAliases.Argument.FilePathArgument") var testAssemblyPath = Context .Environment .ApplicationRoot - .CombineWithFilePath( -#if NETCOREAPP - "Cake.dll" -#else - "Cake.exe" -#endif - ); + .CombineWithFilePath("Cake.dll"); // When var arg = Argument("testAssemblyFilePath"); diff --git a/tests/integration/Cake.Common/ProcessAliases.cake b/tests/integration/Cake.Common/ProcessAliases.cake index 4c3e42f48e..42b73604b8 100644 --- a/tests/integration/Cake.Common/ProcessAliases.cake +++ b/tests/integration/Cake.Common/ProcessAliases.cake @@ -7,7 +7,8 @@ Task("Cake.Common.ProcessAliases.StartProcess") .Does(() => { // Given - var fileName = Context.Tools.Resolve("Cake.exe"); + var fileName = Context.Tools.Resolve("dotnet.exe") + ?? Context.Tools.Resolve("dotnet"); var argument = "--version"; // When @@ -21,9 +22,11 @@ Task("Cake.Common.ProcessAliases.StartProcess.Output") .Does(() => { // Given - var fileName = Context.Tools.Resolve("Cake.exe"); - var argument = "--version"; - var version = FileVersionInfo.GetVersionInfo(typeof(ICakeContext).GetTypeInfo().Assembly.Location).Comments; + var fileName = Context.Tools.Resolve("dotnet.exe") + ?? Context.Tools.Resolve("dotnet"); + var coreLocation = typeof(ICakeContext).GetTypeInfo().Assembly.Location; + var argument = $"{coreLocation.Replace(".Core","")} --version"; + var version = FileVersionInfo.GetVersionInfo(coreLocation).Comments; // When IEnumerable redirectedStandardOutput; diff --git a/tests/integration/Cake.Core/Scripting/AddinDirective.cake b/tests/integration/Cake.Core/Scripting/AddinDirective.cake index f797c664d5..d0c9f94a3f 100644 --- a/tests/integration/Cake.Core/Scripting/AddinDirective.cake +++ b/tests/integration/Cake.Core/Scripting/AddinDirective.cake @@ -1,14 +1,34 @@ #addin nuget:?package=Cake.Kudu.Client&version=0.9.0 -Task("Cake.Core.Scripting.AddinDirective.LoadNetStandardAddin") +Task("Cake.Core.Scripting.AddinDirective.LoadTargetedAddin") .Does(() => { - DotNetCorePack($"{Paths.Resources}/Cake.Core/Scripting/netstandard2.addin/netstandard2.addin.csproj", + CleanDirectories($"{Paths.Resources}/Cake.Core/Scripting/addin/{{bin,obj}}"); + + FilePath cakeCore = typeof(ICakeContext).GetTypeInfo().Assembly.Location; + FilePath cake = cakeCore.GetDirectory().CombineWithFilePath("Cake.dll"); + + var msBuildSettings = new DotNetCoreMSBuildSettings + { + Version = "1.0.0", + } + .WithProperty("CakeCorePath", typeof(ICakeContext).GetTypeInfo().Assembly.Location) + .SetTargetFramework( + cake switch + { + FilePath netCoreApp3_1Path when netCoreApp3_1Path.FullPath.Contains("netcoreapp3.1") => "netcoreapp3.1", + FilePath net5_0Path when net5_0Path.FullPath.Contains("net5.0") => "net5.0", + _ => "net6.0" + } + ); + + DotNetCorePack($"{Paths.Resources}/Cake.Core/Scripting/addin/addin.csproj", new DotNetCorePackSettings { - Configuration = "Release" + Configuration = "Release", + MSBuildSettings = msBuildSettings }); - var script = $@"#addin nuget:{Paths.Resources}/Cake.Core/Scripting/netstandard2.addin/bin/Release?package=netstandard2.addin&version=1.0.0 + var script = $@"#addin nuget:{Paths.Resources}/Cake.Core/Scripting/addin/bin/Release?package=addin&version=1.0.0 Information(""Magic number: {0}"", GetMagicNumber(false)); Information(""The answer to life: {0}"", TheAnswerToLife); Information(""Get Dynamic Magic Number: {0}"", GetDynamicMagicNumber(false).MagicNumber); @@ -21,7 +41,10 @@ Task("Cake.Core.Scripting.AddinDirective.LoadNetStandardAddin") {"CAKE_PATHS_ADDINS", $"{Paths.Temp}/tools/Addins"}, {"CAKE_PATHS_TOOLS", $"{Paths.Temp}/tools"}, {"CAKE_PATHS_MODULES", $"{Paths.Temp}/tools/Modules"}, + {"NUGET_PACKAGES", $"{Paths.Temp}/nuget/Packages"}, + {"NUGET_HTTP_CACHE_PATH ", $"{Paths.Temp}/nuget/Cache"} }, + ToolPath = cake, Verbosity = Context.Log.Verbosity }); }); @@ -35,5 +58,5 @@ Task("Cake.Core.Scripting.AddinDirective.CallDuplicatedMethod") ////////////////////////////////////////////////////////////////////////////// Task("Cake.Core.Scripting.AddinDirective") - .IsDependentOn("Cake.Core.Scripting.AddinDirective.LoadNetStandardAddin") + .IsDependentOn("Cake.Core.Scripting.AddinDirective.LoadTargetedAddin") .IsDependentOn("Cake.Core.Scripting.AddinDirective.CallDuplicatedMethod"); \ No newline at end of file diff --git a/tests/integration/Cake.Frosting/build/Build.csproj b/tests/integration/Cake.Frosting/build/Build.csproj index 408d33e81a..2310bf0411 100644 --- a/tests/integration/Cake.Frosting/build/Build.csproj +++ b/tests/integration/Cake.Frosting/build/Build.csproj @@ -2,7 +2,7 @@ Exe - net461;netcoreapp2.1;netcoreapp3.0;net5.0;net6.0 + netcoreapp3.1;net5.0;net6.0 true diff --git a/tests/integration/resources/Cake.Common/Tools/DotNetCore/hwapp.tests/hwapp.tests.csproj b/tests/integration/resources/Cake.Common/Tools/DotNetCore/hwapp.tests/hwapp.tests.csproj index 1eb12b6162..681b019590 100644 --- a/tests/integration/resources/Cake.Common/Tools/DotNetCore/hwapp.tests/hwapp.tests.csproj +++ b/tests/integration/resources/Cake.Common/Tools/DotNetCore/hwapp.tests/hwapp.tests.csproj @@ -6,11 +6,10 @@ - - + + - - + diff --git a/tests/integration/resources/Cake.Core/Scripting/netstandard2.addin/MyCakeExtension.cs b/tests/integration/resources/Cake.Core/Scripting/addin/MyCakeExtension.cs similarity index 100% rename from tests/integration/resources/Cake.Core/Scripting/netstandard2.addin/MyCakeExtension.cs rename to tests/integration/resources/Cake.Core/Scripting/addin/MyCakeExtension.cs diff --git a/tests/integration/resources/Cake.Core/Scripting/addin/addin.csproj b/tests/integration/resources/Cake.Core/Scripting/addin/addin.csproj new file mode 100644 index 0000000000..661536b03a --- /dev/null +++ b/tests/integration/resources/Cake.Core/Scripting/addin/addin.csproj @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/integration/resources/Cake.Core/Scripting/netstandard2.addin/netstandard2.addin.csproj b/tests/integration/resources/Cake.Core/Scripting/netstandard2.addin/netstandard2.addin.csproj deleted file mode 100644 index 4357f7162f..0000000000 --- a/tests/integration/resources/Cake.Core/Scripting/netstandard2.addin/netstandard2.addin.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - netstandard2.0 - - - - - - -