diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 02c4689a..00000000 --- a/.appveyor.yml +++ /dev/null @@ -1,19 +0,0 @@ -image: - - Visual Studio 2019 - -test: off -build: off - -skip_branch_with_pr: true -branches: - only: - - develop - - master - - /release/.*/ - - /hotfix/.*/ - -build_script: - - ps: .\build.ps1 --target=CI - -cache: -- tools -> recipe.cake diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1ecf8d0a..b2f13d28 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,19 +23,36 @@ jobs: steps: - name: Checkout the repository - uses: actions/checkout@v2 + uses: actions/checkout@v2.4.0 - name: Fetch all tags and branches run: git fetch --prune --unshallow + - uses: actions/setup-dotnet@v1.8.2 + with: + # codecov and unittests need 2.1 + dotnet-version: '2.1.818' + - uses: actions/setup-dotnet@v1.8.2 + with: + dotnet-version: '3.1.414' + - uses: actions/setup-dotnet@v1.8.2 + with: + # gitversion needs 5.0 + dotnet-version: '5.0.402' + - uses: actions/setup-dotnet@v1.8.2 + with: + # need at least .NET 6 rc2 to build + dotnet-version: '6.0.100-rc.2.21505.57' + include-prerelease: true + - name: Cache Tools - uses: actions/cache@v2 + uses: actions/cache@v2.1.6 with: path: tools key: ${{ runner.os }}-tools-${{ hashFiles('recipe.cake') }} - name: Build project - uses: cake-build/cake-action@v1 + uses: cake-build/cake-action@v1.4.0 with: script-path: recipe.cake target: CI diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 820e28b8..ba8a6ea6 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -20,12 +20,29 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v2.4.0 with: fetch-depth: 0 + - uses: actions/setup-dotnet@v1.8.2 + with: + # codecov and unittests need 2.1 + dotnet-version: '2.1.818' + - uses: actions/setup-dotnet@v1.8.2 + with: + dotnet-version: '3.1.414' + - uses: actions/setup-dotnet@v1.8.2 + with: + # gitversion needs 5.0 + dotnet-version: '5.0.402' + - uses: actions/setup-dotnet@v1.8.2 + with: + # need at least .NET 6 rc2 to build + dotnet-version: '6.0.100-rc.2.21505.57' + include-prerelease: true + - name: Cache Tools - uses: actions/cache@v2 + uses: actions/cache@v2.1.6 with: path: tools key: ${{ runner.os }}-tools-${{ hashFiles('recipe.cake') }} @@ -36,7 +53,7 @@ jobs: languages: ${{ matrix.language }} - name: Build project - uses: cake-build/cake-action@v1 + uses: cake-build/cake-action@v1.4.0 with: script-path: recipe.cake target: DotNetCore-Build diff --git a/.github/workflows/dependabot-cake.yml b/.github/workflows/dependabot-cake.yml index f34a9670..edc633ea 100644 --- a/.github/workflows/dependabot-cake.yml +++ b/.github/workflows/dependabot-cake.yml @@ -10,4 +10,4 @@ jobs: runs-on: ubuntu-latest # linux, because this is a docker-action steps: - name: check/update cake dependencies - uses: nils-org/dependabot-cake-action@v1 \ No newline at end of file + uses: nils-org/dependabot-cake-action@v1.1.0 \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..6e2ca50b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "cSpell.words": [ + "Buildsystems", + "nuget" + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 803fb4b7..665eb30b 100644 --- a/README.md +++ b/README.md @@ -60,9 +60,34 @@ Currently modules require "bootstrapping", so the first step before running the ### Other methods -You can also integrate this module into your own build process, even with a customised `build.ps1`/`build.sh`. As long as the `Cake.BuildSystems.Module` NuGet package is installed into your modules directory ([by default](https://cakebuild.net/docs/running-builds/configuration/default-configuration-values) `./tools/Modules`), `cake.exe` should pick them up when it runs. Note that you can also change your modules directory using the `cake.config` file or passing arguments to `cake.exe` as outlined in [the documentation](https://cakebuild.net/docs/running-builds/configuration/set-configuration-values)). +You can also integrate this module into your own build process, even with a customized `build.ps1`/`build.sh`. As long as the `Cake.BuildSystems.Module` NuGet package is installed into your modules directory ([by default](https://cakebuild.net/docs/running-builds/configuration/default-configuration-values) `./tools/Modules`), `cake.exe` should pick them up when it runs. Note that you can also change your modules directory using the `cake.config` file or passing arguments to `cake.exe` as outlined in [the documentation](https://cakebuild.net/docs/running-builds/configuration/set-configuration-values)). -### Versioning +### Cake.Frosting + +While Cake script will load all modules automatically that are present in the modules directory, the same is not the case when using Cake.Frosting. + +Before using Cake.Buildsystems.Module you have to reference the NuGet package either by adding `` to the `csproj` file of the build project, or by running `dotnet add package cake.buildsystems.module` in the folder of the build project. + +To actually make use of the different modules included in Cake.Buildsystems.Module they need to be registered to the `CakeHost`. This can be done by using `ICakeHost.UseModule()`. Typically the `CakeHost` is set up in the `Main` method of the build project. All modules included in Cake.Buildsystems.Module can be registered, regardless of the underlying build system, as each modules will only be triggered for the intended build system. + +An example that registers all currently existing modules from Cake.Buildsystems.Module: + +```csharp +public static int Main(string[] args) +{ + return new CakeHost() + // Register all modules from Cake.Buildsystems.Module + .UseModule() + .UseModule() + .UseModule() + .UseModule() + // continue with the "normal" setup of the CakeHost + .UseContext() + .Run(args); +} +``` + +## Versioning Note that since modules interact with the internals of Cake, they are tied to a specific version of Cake. The version of Cake supported by the particular module version will always be in the Release Notes of the NuGet package (and therefore also on [nuget.org](https://nuget.org/packages/Cake.BuildSystems.Module/)). Make sure to match this version number to the Cake version you're using. diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 1456cde9..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,27 +0,0 @@ -pool: - vmImage: 'windows-latest' - -trigger: - branches: - include: - - master - - develop - - 'release/*' - - 'hotfix/*' - - 'feature/*' - - tags: - include: [] - -steps: -- task: Cache@2 - inputs: - key: '"$(Agent.OS)" | recipe.cake' - path: 'tools' -- task: Cake@2 - inputs: - script: 'recipe.cake' - target: 'CI' - verbosity: 'Diagnostic' - Bootstrap: true - Version: '0.38.5' diff --git a/demo/dsl/.config/dotnet-tools.json b/demo/dsl/.config/dotnet-tools.json new file mode 100644 index 00000000..6cf141eb --- /dev/null +++ b/demo/dsl/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "cake.tool": { + "version": "1.1.0", + "commands": [ + "dotnet-cake" + ] + } + } +} \ No newline at end of file diff --git a/demo/dsl/build.cake b/demo/dsl/build.cake new file mode 100644 index 00000000..e563748c --- /dev/null +++ b/demo/dsl/build.cake @@ -0,0 +1,23 @@ +#module nuget:?package=Cake.BuildSystems.Module&version=3.0.3 + +/////////////////////////////////////////////////////////////////////////////// +// ARGUMENTS +/////////////////////////////////////////////////////////////////////////////// + +var target = Argument("target", "Default"); + +/////////////////////////////////////////////////////////////////////////////// +// TASKS +/////////////////////////////////////////////////////////////////////////////// + +Task("Default") +.Does(() => { + Information("Hello Cake!"); + Verbose("This is really verbose."); + Warning("This is a warning."); + Debug("This is a debug-message."); + Information("Next comes the error:"); + Error("This is an error."); +}); + +RunTarget(target); diff --git a/demo/dsl/build.ps1 b/demo/dsl/build.ps1 new file mode 100644 index 00000000..21821d29 --- /dev/null +++ b/demo/dsl/build.ps1 @@ -0,0 +1,13 @@ +$ErrorActionPreference = 'Stop' + +Set-Location -LiteralPath $PSScriptRoot + +$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1' +$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1' +$env:DOTNET_NOLOGO = '1' + +dotnet tool restore +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + +dotnet cake @args +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } diff --git a/demo/dsl/build.sh b/demo/dsl/build.sh new file mode 100644 index 00000000..31be8865 --- /dev/null +++ b/demo/dsl/build.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -euox pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")" + +export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +export DOTNET_CLI_TELEMETRY_OPTOUT=1 +export DOTNET_NOLOGO=1 + +dotnet tool restore + +dotnet cake "$@" diff --git a/demo/frosting/build.ps1 b/demo/frosting/build.ps1 new file mode 100644 index 00000000..a7077190 --- /dev/null +++ b/demo/frosting/build.ps1 @@ -0,0 +1,2 @@ +dotnet run --project build/Build.csproj -- $args +exit $LASTEXITCODE; \ No newline at end of file diff --git a/demo/frosting/build.sh b/demo/frosting/build.sh new file mode 100644 index 00000000..dfd6b854 --- /dev/null +++ b/demo/frosting/build.sh @@ -0,0 +1 @@ +dotnet run --project ./build/Build.csproj -- "$@" diff --git a/demo/frosting/build/Build.csproj b/demo/frosting/build/Build.csproj new file mode 100644 index 00000000..fe69fab5 --- /dev/null +++ b/demo/frosting/build/Build.csproj @@ -0,0 +1,12 @@ + + + Exe + netcoreapp3.1 + $(MSBuildProjectDirectory) + + + + + + + diff --git a/demo/frosting/build/Program.cs b/demo/frosting/build/Program.cs new file mode 100644 index 00000000..c2002303 --- /dev/null +++ b/demo/frosting/build/Program.cs @@ -0,0 +1,46 @@ +using Cake.AzurePipelines.Module; +using Cake.Common.Diagnostics; +using Cake.Core; +using Cake.Frosting; +using Cake.MyGet.Module; +using Cake.TeamCity.Module; +using Cake.TravisCI.Module; +using JetBrains.Annotations; + +public static class Program +{ + public static int Main(string[] args) + { + return new CakeHost() + // Register all modules from Cake.Buildsystems.Module + .UseModule() + .UseModule() + .UseModule() + .UseModule() + .UseContext() + .Run(args); + } +} + +public class BuildContext : FrostingContext +{ + public BuildContext(ICakeContext context) + : base(context) + { + } +} + +[TaskName("Default")] +[UsedImplicitly] +public class DefaultTask : FrostingTask +{ + public override void Run(ICakeContext context) + { + context.Information("Hello Cake!"); + context.Verbose("This is really verbose."); + context.Warning("This is a warning."); + context.Debug("This is a debug-message."); + context.Information("Next comes the error:"); + context.Error("This is an error."); + } +} diff --git a/global.json b/global.json new file mode 100644 index 00000000..e5b7df50 --- /dev/null +++ b/global.json @@ -0,0 +1,7 @@ +{ + "sdk": { + "allowPrerelease": true, + "version": "6.0.100-rc.2", + "rollForward": "latestFeature" + } +} \ No newline at end of file diff --git a/recipe.cake b/recipe.cake index 863bfc3b..877bbad6 100644 --- a/recipe.cake +++ b/recipe.cake @@ -14,10 +14,15 @@ BuildParameters.SetParameters( shouldRunDotNetCorePack: true, shouldUseDeterministicBuilds: true, gitterMessage: "@/all " + standardNotificationMessage, - twitterMessage: standardNotificationMessage); + twitterMessage: standardNotificationMessage, + preferredBuildProviderType: BuildProviderType.GitHubActions, + preferredBuildAgentOperatingSystem: PlatformFamily.Linux); BuildParameters.PrintParameters(Context); ToolSettings.SetToolSettings(context: Context); +ToolSettings.SetToolPreprocessorDirectives( + reSharperTools: "#tool nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2021.2.0"); + Build.RunDotNetCore(); diff --git a/src/Cake.AzurePipelines.Module/Cake.AzurePipelines.Module.csproj b/src/Cake.AzurePipelines.Module/Cake.AzurePipelines.Module.csproj index b788c61f..b3d38b64 100644 --- a/src/Cake.AzurePipelines.Module/Cake.AzurePipelines.Module.csproj +++ b/src/Cake.AzurePipelines.Module/Cake.AzurePipelines.Module.csproj @@ -14,8 +14,8 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Cake.BuildSystems.Module/Cake.BuildSystems.Module.csproj b/src/Cake.BuildSystems.Module/Cake.BuildSystems.Module.csproj index fc5b276d..090d3bce 100644 --- a/src/Cake.BuildSystems.Module/Cake.BuildSystems.Module.csproj +++ b/src/Cake.BuildSystems.Module/Cake.BuildSystems.Module.csproj @@ -23,6 +23,7 @@ This Cake module will introduce a number of features for running in hosted CI build environments to tightly integrate with the host environment/tools. MIT https://github.com/cake-contrib/Cake.BuildSystems.Module/ + README.md cake;build;script;cake-build;module;cake-contrib;cake-module;ci;tfs;azure-devops;azure-devops-server;myget;teamcity;travisci https://github.com/cake-contrib/Cake.BuildSystems.Module.git git @@ -44,12 +45,13 @@ + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Cake.Module.Shared/Cake.Module.Shared.csproj b/src/Cake.Module.Shared/Cake.Module.Shared.csproj index 0607bff3..efe873d5 100644 --- a/src/Cake.Module.Shared/Cake.Module.Shared.csproj +++ b/src/Cake.Module.Shared/Cake.Module.Shared.csproj @@ -10,8 +10,8 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Cake.MyGet.Module/Cake.MyGet.Module.csproj b/src/Cake.MyGet.Module/Cake.MyGet.Module.csproj index 215ce015..8cdebe6d 100644 --- a/src/Cake.MyGet.Module/Cake.MyGet.Module.csproj +++ b/src/Cake.MyGet.Module/Cake.MyGet.Module.csproj @@ -14,8 +14,8 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Cake.TeamCity.Module/Cake.TeamCity.Module.csproj b/src/Cake.TeamCity.Module/Cake.TeamCity.Module.csproj index 6accca44..450d94cc 100644 --- a/src/Cake.TeamCity.Module/Cake.TeamCity.Module.csproj +++ b/src/Cake.TeamCity.Module/Cake.TeamCity.Module.csproj @@ -14,8 +14,8 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Cake.TravisCI.Module/Cake.TravisCI.Module.csproj b/src/Cake.TravisCI.Module/Cake.TravisCI.Module.csproj index 278bfcdf..2c58a077 100644 --- a/src/Cake.TravisCI.Module/Cake.TravisCI.Module.csproj +++ b/src/Cake.TravisCI.Module/Cake.TravisCI.Module.csproj @@ -14,8 +14,8 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all