From a2f7997dfc74858c454874073c52b15185473630 Mon Sep 17 00:00:00 2001 From: Nils Andresen Date: Fri, 30 Oct 2020 23:24:52 +0100 Subject: [PATCH] (GH-28) added the current Cake.Recipe Also I introduced a "shim" project to create the NuGet package instead of the nuspec and updated the README. --- .appveyor.yml | 19 ++ .config/dotnet-tools.json | 12 ++ .gitattributes | 21 ++ .gitignore | 6 +- GitReleaseManager.yaml | 34 +++ LICENSE | 2 +- README.md | 20 +- ReleaseNotes.md | 55 ----- azure-pipelines.yml | 63 +++--- build.cake | 136 ------------ build.ps1 | 195 +----------------- build.sh | 103 +-------- cake.config | 13 -- helpers.cake | 37 ---- recipe.cake | 23 +++ .../Cake.AzurePipelines.Module.csproj | 3 +- src/Cake.BuildSystems.Module.sln | 18 +- .../Cake.BuildSystems.Module.csproj | 59 ++++++ src/Cake.BuildSystems.Module/Readme.txt | 2 + .../Cake.Module.Shared.csproj | 2 +- .../Properties/AssemblyInfo.cs | 26 --- .../Cake.MyGet.Module.csproj | 3 +- .../Cake.TeamCity.Module.csproj | 3 +- .../Cake.TravisCI.Module.csproj | 3 +- tools/packages.config | 4 - 25 files changed, 246 insertions(+), 616 deletions(-) create mode 100644 .appveyor.yml create mode 100644 .config/dotnet-tools.json create mode 100644 .gitattributes create mode 100644 GitReleaseManager.yaml delete mode 100644 ReleaseNotes.md delete mode 100644 build.cake delete mode 100644 cake.config delete mode 100644 helpers.cake create mode 100644 recipe.cake create mode 100644 src/Cake.BuildSystems.Module/Cake.BuildSystems.Module.csproj create mode 100644 src/Cake.BuildSystems.Module/Readme.txt delete mode 100644 src/Cake.Module.Shared/Properties/AssemblyInfo.cs delete mode 100644 tools/packages.config diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 00000000..02c4689a --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,19 @@ +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/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 00000000..727dfd76 --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "cake.tool": { + "version": "0.38.5", + "commands": [ + "dotnet-cake" + ] + } + } +} \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..3dde06ea --- /dev/null +++ b/.gitattributes @@ -0,0 +1,21 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +*.cs text diff=csharp + +*.ps1 text eol=crlf +*.bat text eol=crlf +*.sln text eol=crlf +*.csproj text eol=crlf +tasks.json text eol=crlf + +*.sh text eol=lf + +*.md text whitespace=-trailing-space + +# Exclude files from exporting + +.gitattributes export-ignore +.gitignore export-ignore diff --git a/.gitignore b/.gitignore index d356c717..07ee9a33 100644 --- a/.gitignore +++ b/.gitignore @@ -271,7 +271,7 @@ __pycache__/ *.pyc # Cake - Uncomment if you are using it -tools/** -!tools/packages.config +tools/ -dist/** \ No newline at end of file +[Bb]uild[Aa]rtifacts/ +/src/Cake.BuildSystems.Module/icon.png \ No newline at end of file diff --git a/GitReleaseManager.yaml b/GitReleaseManager.yaml new file mode 100644 index 00000000..3f5654f2 --- /dev/null +++ b/GitReleaseManager.yaml @@ -0,0 +1,34 @@ +create: + include-footer: true + footer-heading: Where to get it + footer-content: > + You can download this release from + [nuget](https://nuget.org/packages/Cake.BuildSystems.Module/{milestone}), + or you can just reference it in a cake build script + with `#module nuget:?package=Cake.BuildSystems.Module&version={milestone}`. + footer-includes-milestone: true + milestone-replace-text: "{milestone}" +export: + include-created-date-in-title: true + created-date-string-format: yyyy-MM-dd + perform-regex-removal: true + regex-text: '[\r\n]*### Where to get it[\r\n]*You can .*`\.[\r\n]*' + multiline-regex: true +issue-labels-include: + - Breaking change + - Bug + - Feature + - Enhancement + - Improvement + - Documentation + - security +issue-labels-exclude: + - Build + - Internal / Refactoring +issue-labels-alias: + - name: Documentation + header: Documentation + plural: Documentation + - name: security + header: Security + plural: Security diff --git a/LICENSE b/LICENSE index 5663e42d..bbce1d82 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 Alistair Chapman +Copyright (c) 2017-2021 Alistair Chapman Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index d6b6b8b0..803fb4b7 100644 --- a/README.md +++ b/README.md @@ -45,22 +45,22 @@ Each build system's functionality resides in its own module, with `Cake.Module.S ## Installation -### Using the latest bootstrapper +### Using the pre-processor directives -If you're using the latest bootstrapper example (always available in [this repo](https://github.com/cake-build/resources)), you can simply add a `tools/Modules/packages.config` file with the following contents: +Add the next following line to your Cake script: -```xml - - - - +```cs +#module nuget:?package=Cake.BuildSystems.Module&version=##see below for note on versioning## ``` -The next time you run the bootstrapper, the modules should be installed. +Note: The current version can always be taken from [nuget.org](https://nuget.org/packages/Cake.BuildSystems.Module/)). + +Currently modules require "bootstrapping", so the first step before running the build is to call `dotnet cake --bootstrap` +(or `.\build.ps1 --bootstrap`) ### 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](http://cakebuild.net/docs/fundamentals/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](http://cakebuild.net/docs/fundamentals/configuration)). +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)). ### Versioning @@ -68,4 +68,4 @@ Note that since modules interact with the internals of Cake, they are tied to a ## Building -Running `build.ps1` with the default target will build all system modules into `dist/modules`. Copy this to `tools/Modules` (you may need to disable the MD5 check if using the bootstrapper) and run your script. \ No newline at end of file +Running `build.ps1` with the default target will build all system modules into `BuildArtifacts/temp/_PublishedLibraries`. Copy this to `tools/Modules` (you may need to disable the MD5 check if using the bootstrapper) and run your script. \ No newline at end of file diff --git a/ReleaseNotes.md b/ReleaseNotes.md deleted file mode 100644 index f8599eeb..00000000 --- a/ReleaseNotes.md +++ /dev/null @@ -1,55 +0,0 @@ -# 0.1.0 - -- Supports Cake 0.19.4 -- Initial release with support for Team City and TF Build -- Experimental support for Travis CI and MyGet Build Services - -# 0.1.1 - -- Supports Cake 0.19.5 - -# 0.1.2 - -- Supports Cake 0.19.5 -- Fix for naming and accessibility of TF Build module - -# 0.1.3 - -- Supports Cake 0.20.0 - -# 0.1.4 - -- Supports Cake 0.21.1 - -# 0.1.5 - -- Supports Cake 0.22.2 - -# 0.2.0 - -- Supports Cake 0.24.0 -- Updated to use new logging implementation - -# 0.3.0 - -- Supports Cake 0.28.1 -- Updated with fixed TC engine, including new build statistics -- Other small fixes -- Thanks @flcdrg and @micsco for contributions! - -# 0.3.1 - -- Supports Cake 0.30.0 -- Retargeted to .NET Standard 2.0 (raise issues if you see new issues from this) -- Thanks again to @flcdrg and @RaringCoder for contributions and testing! - -# 0.3.2 - -- Supports Cake 0.34.1 -- Fixes errors writing summary report when run in Azure Pipelines container (#21) -- Thanks again to @flcdrg for contributions! - -# 0.4.0 - -- Supports Cake 0.38.0 -- Rename TF Build to Azure Pipelines diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 619d191f..1456cde9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,44 +1,27 @@ +pool: + vmImage: 'windows-latest' + trigger: - - master - - develop + branches: + include: + - master + - develop + - 'release/*' + - 'hotfix/*' + - 'feature/*' -variables: - buildConfiguration: 'Release' - cakeVersion: 0.38.5 - sdkVersion: '2.2.300' - target: NuGet + tags: + include: [] -pool: - vmImage: 'windows-2019' steps: - - task: UseDotNet@2 - displayName: 'Use .NET Core SDK' - inputs: - packageType: sdk - version: $(sdkVersion) - installationPath: $(Agent.ToolsDirectory)/dotnet - - task: NuGetToolInstaller@1 - inputs: - versionSpec: '>=5.x' - - task: DotNetCoreCLI@2 - displayName: Install Cake tool - inputs: - command: custom - custom: tool - arguments: install -g Cake.Tool --version $(cakeVersion) - - task: DotNetCoreCLI@2 - displayName: Run build - inputs: - command: custom - custom: cake - arguments: --settings_skipverification=true --target=$(target) - - task: PublishPipelineArtifact@1 - displayName: Publish packages artifact - inputs: - path: dist/package - artifact: package - - task: PublishPipelineArtifact@1 - displayName: Publish build output - inputs: - path: dist/build - artifact: publish \ No newline at end of file +- 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/build.cake b/build.cake deleted file mode 100644 index 51af22cc..00000000 --- a/build.cake +++ /dev/null @@ -1,136 +0,0 @@ -#load "helpers.cake" -#tool "nuget:?package=GitVersion.CommandLine" - -/////////////////////////////////////////////////////////////////////////////// -// ARGUMENTS -/////////////////////////////////////////////////////////////////////////////// - -var target = Argument("target", "Default"); -var configuration = Argument("configuration", "Release"); - -/////////////////////////////////////////////////////////////////////////////// -// GLOBAL VARIABLES -/////////////////////////////////////////////////////////////////////////////// - -var solutionPath = File("./src/Cake.BuildSystems.Module.sln"); -var projects = GetProjects(solutionPath); -var artifacts = "./dist/"; -var testResultsPath = MakeAbsolute(Directory(artifacts + "./test-results")); -GitVersion versionInfo = null; -var frameworks = new List { "netstandard2.0"}; - -/////////////////////////////////////////////////////////////////////////////// -// SETUP / TEARDOWN -/////////////////////////////////////////////////////////////////////////////// - -Setup(ctx => -{ - // Executed BEFORE the first task. - Information("Running tasks..."); - versionInfo = GitVersion(); - Debug("Using projects: " + string.Join(", ", projects.SourceProjects.Select(p => p.Name))); - //Information("Building for version {0}", versionInfo.FullSemVer); -}); - -Teardown(ctx => -{ - // Executed AFTER the last task. - Information("Finished running tasks."); -}); - -/////////////////////////////////////////////////////////////////////////////// -// TASK DEFINITIONS -/////////////////////////////////////////////////////////////////////////////// - -Task("Clean") - .Does(() => -{ - // Clean solution directories. - foreach(var path in projects.AllProjectPaths) - { - Information("Cleaning {0}", path); - CleanDirectories(path + "/**/bin/" + configuration); - CleanDirectories(path + "/**/obj/" + configuration); - } - Information("Cleaning common files..."); - CleanDirectory(artifacts); - DeleteFiles(GetFiles("./**/*.temp.nuspec")); -}); - -Task("Restore") - .Does(() => -{ - // Restore all NuGet packages. - Information("Restoring solution..."); - foreach (var project in projects.AllProjectPaths) { - DotNetCoreRestore(project.FullPath); - } -}); - -Task("Build") - .IsDependentOn("Clean") - .IsDependentOn("Restore") - .Does(() => -{ - Information("Building solution..."); - foreach(var framework in frameworks) { - foreach (var project in projects.SourceProjectPaths) { - var settings = new DotNetCoreBuildSettings { - Framework = framework, - Configuration = configuration, - NoIncremental = true, - }; - DotNetCoreBuild(project.FullPath, settings); - } - } - -}); - -Task("Post-Build") - .IsDependentOn("Build") - .Does(() => -{ - CreateDirectory(artifacts + "build"); - CreateDirectory(artifacts + "modules"); - foreach (var project in projects.SourceProjects) { - CreateDirectory(artifacts + "build/" + project.Name); - var files = GetFiles(project.Path.GetDirectory() + "/bin/" + configuration + "/net46/" + project.Name +".*"); - CopyFiles(files, artifacts + "build/" + project.Name); - CopyFiles(files, artifacts + "modules/"); - } -}); - -Task("NuGet") - .IsDependentOn("Post-Build") - .Does(() => -{ - CreateDirectory(artifacts + "package"); - Information("Building NuGet package"); - var versionNotes = ParseAllReleaseNotes("./ReleaseNotes.md").FirstOrDefault(v => v.Version.ToString() == versionInfo.MajorMinorPatch); - var content = GetContent(frameworks, projects); - var settings = new NuGetPackSettings { - Id = "Cake.BuildSystems.Module", - Version = versionInfo.NuGetVersionV2, - Title = "Cake Build Systems Module", - Authors = new[] { "Alistair Chapman" }, - Owners = new[] { "achapman", "cake-contrib" }, - Description = "This Cake module will introduce a number of features for running in hosted CI build environments to tightly integrate with the host environment/tools.", - ReleaseNotes = versionNotes != null ? versionNotes.Notes.ToList() : new List(), - Summary = "A simple Cake module to enhance running from a hosted CI environment.", - ProjectUrl = new Uri("https://github.com/agc93/Cake.BuildSystems.Module"), - IconUrl = new Uri("https://cdn.rawgit.com/cake-contrib/graphics/a5cf0f881c390650144b2243ae551d5b9f836196/png/cake-contrib-medium.png"), - License = new NuSpecLicense() { Type = "expression", Value = "MIT" }, - Copyright = "Alistair Chapman 2017", - Tags = new[] { "cake", "build", "ci", "build" }, - OutputDirectory = artifacts + "/package", - Files = content, - //KeepTemporaryNuSpecFile = true - }; - - NuGetPack(settings); -}); - -Task("Default") - .IsDependentOn("Post-Build"); - -RunTarget(target); diff --git a/build.ps1 b/build.ps1 index 44de5793..210aea29 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,189 +1,16 @@ -########################################################################## -# This is the Cake bootstrapper script for PowerShell. -# This file was downloaded from https://github.com/cake-build/resources -# Feel free to change this file to fit your needs. -########################################################################## +$ErrorActionPreference = 'Stop' -<# +Set-Location -LiteralPath $PSScriptRoot -.SYNOPSIS -This is a Powershell script to bootstrap a Cake build. +$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1' +$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1' +$env:DOTNET_NOLOGO = '1' -.DESCRIPTION -This Powershell script will download NuGet if missing, restore NuGet tools (including Cake) -and execute your Cake build script with the parameters you provide. +dotnet tool restore +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } -.PARAMETER Script -The build script to execute. -.PARAMETER Target -The build script target to run. -.PARAMETER Configuration -The build configuration to use. -.PARAMETER Verbosity -Specifies the amount of information to be displayed. -.PARAMETER Experimental -Tells Cake to use the latest Roslyn release. -.PARAMETER WhatIf -Performs a dry run of the build script. -No tasks will be executed. -.PARAMETER Mono -Tells Cake to use the Mono scripting engine. -.PARAMETER SkipToolPackageRestore -Skips restoring of packages. -.PARAMETER ScriptArgs -Remaining arguments are added here. +dotnet cake recipe.cake --bootstrap +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } -.LINK -http://cakebuild.net - -#> - -[CmdletBinding()] -Param( - [string]$Script = "build.cake", - [string]$Target = "Default", - [ValidateSet("Release", "Debug")] - [string]$Configuration = "Release", - [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] - [string]$Verbosity = "Verbose", - [switch]$Experimental, - [Alias("DryRun","Noop")] - [switch]$WhatIf, - [switch]$Mono, - [switch]$SkipToolPackageRestore, - [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] - [string[]]$ScriptArgs -) - -[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null -function MD5HashFile([string] $filePath) -{ - if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf)) - { - return $null - } - - [System.IO.Stream] $file = $null; - [System.Security.Cryptography.MD5] $md5 = $null; - try - { - $md5 = [System.Security.Cryptography.MD5]::Create() - $file = [System.IO.File]::OpenRead($filePath) - return [System.BitConverter]::ToString($md5.ComputeHash($file)) - } - finally - { - if ($file -ne $null) - { - $file.Dispose() - } - } -} - -Write-Host "Preparing to run build script..." - -if(!$PSScriptRoot){ - $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent -} - -$TOOLS_DIR = Join-Path $PSScriptRoot "tools" -$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe" -$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe" -$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config" -$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum" - -# Should we use mono? -$UseMono = ""; -if($Mono.IsPresent) { - Write-Verbose -Message "Using the Mono based scripting engine." - $UseMono = "-mono" -} - -# Should we use the new Roslyn? -$UseExperimental = ""; -if($Experimental.IsPresent -and !($Mono.IsPresent)) { - Write-Verbose -Message "Using experimental version of Roslyn." - $UseExperimental = "-experimental" -} - -# Is this a dry run? -$UseDryRun = ""; -if($WhatIf.IsPresent) { - $UseDryRun = "-dryrun" -} - -# Make sure tools folder exists -if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) { - Write-Verbose -Message "Creating tools directory..." - New-Item -Path $TOOLS_DIR -Type directory | out-null -} - -# Make sure that packages.config exist. -if (!(Test-Path $PACKAGES_CONFIG)) { - Write-Verbose -Message "Downloading packages.config..." - try { (New-Object System.Net.WebClient).DownloadFile("http://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch { - Throw "Could not download packages.config." - } -} - -# Try find NuGet.exe in path if not exists -if (!(Test-Path $NUGET_EXE)) { - Write-Verbose -Message "Trying to find nuget.exe in PATH..." - $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_) } - $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1 - if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) { - Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)." - $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName - } -} - -# Try download NuGet.exe if not exists -if (!(Test-Path $NUGET_EXE)) { - Write-Verbose -Message "Downloading NuGet.exe..." - try { - (New-Object System.Net.WebClient).DownloadFile($NUGET_URL, $NUGET_EXE) - } catch { - Throw "Could not download NuGet.exe." - } -} - -# Save nuget.exe path to environment to be available to child processed -$ENV:NUGET_EXE = $NUGET_EXE - -# Restore tools from NuGet? -if(-Not $SkipToolPackageRestore.IsPresent) { - Push-Location - Set-Location $TOOLS_DIR - - # Check for changes in packages.config and remove installed tools if true. - [string] $md5Hash = MD5HashFile($PACKAGES_CONFIG) - if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or - ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { - Write-Verbose -Message "Missing or changed package.config hash..." - Remove-Item * -Recurse -Exclude packages.config,nuget.exe - } - - Write-Verbose -Message "Restoring tools from NuGet..." - $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`"" - - if ($LASTEXITCODE -ne 0) { - Throw "An error occured while restoring NuGet tools." - } - else - { - $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII" - } - Write-Verbose -Message ($NuGetOutput | out-string) - Pop-Location -} - -# Make sure that Cake has been installed. -if (!(Test-Path $CAKE_EXE)) { - Throw "Could not find Cake.exe at $CAKE_EXE" -} - -# Start Cake -Write-Host "Running build script..." -Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs" -exit $LASTEXITCODE \ No newline at end of file +dotnet cake recipe.cake @args +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } diff --git a/build.sh b/build.sh index 6e8f207c..034798ea 100755 --- a/build.sh +++ b/build.sh @@ -1,101 +1,14 @@ #!/usr/bin/env bash +set -euox pipefail -########################################################################## -# This is the Cake bootstrapper script for Linux and OS X. -# This file was downloaded from https://github.com/cake-build/resources -# Feel free to change this file to fit your needs. -########################################################################## +cd "$(dirname "${BASH_SOURCE[0]}")" -# Define directories. -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -TOOLS_DIR=$SCRIPT_DIR/tools -NUGET_EXE=$TOOLS_DIR/nuget.exe -CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe -PACKAGES_CONFIG=$TOOLS_DIR/packages.config -PACKAGES_CONFIG_MD5=$TOOLS_DIR/packages.config.md5sum +export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +export DOTNET_CLI_TELEMETRY_OPTOUT=1 +export DOTNET_NOLOGO=1 -# Define md5sum or md5 depending on Linux/OSX -MD5_EXE= -if [[ "$(uname -s)" == "Darwin" ]]; then - MD5_EXE="md5 -r" -else - MD5_EXE="md5sum" -fi +dotnet tool restore -# Define default arguments. -SCRIPT="build.cake" -TARGET="Default" -CONFIGURATION="Release" -VERBOSITY="verbose" -DRYRUN= -SHOW_VERSION=false -SCRIPT_ARGUMENTS=() +dotnet cake recipe.cake --bootstrap -# Parse arguments. -for i in "$@"; do - case $1 in - -s|--script) SCRIPT="$2"; shift ;; - -t|--target) TARGET="$2"; shift ;; - -c|--configuration) CONFIGURATION="$2"; shift ;; - -v|--verbosity) VERBOSITY="$2"; shift ;; - -d|--dryrun) DRYRUN="-dryrun" ;; - --version) SHOW_VERSION=true ;; - --) shift; SCRIPT_ARGUMENTS+=("$@"); break ;; - *) SCRIPT_ARGUMENTS+=("$1") ;; - esac - shift -done - -# Make sure the tools folder exist. -if [ ! -d "$TOOLS_DIR" ]; then - mkdir "$TOOLS_DIR" -fi - -# Make sure that packages.config exist. -if [ ! -f "$TOOLS_DIR/packages.config" ]; then - echo "Downloading packages.config..." - curl -Lsfo "$TOOLS_DIR/packages.config" http://cakebuild.net/download/bootstrapper/packages - if [ $? -ne 0 ]; then - echo "An error occured while downloading packages.config." - exit 1 - fi -fi - -# Download NuGet if it does not exist. -if [ ! -f "$NUGET_EXE" ]; then - echo "Downloading NuGet..." - curl -Lsfo "$NUGET_EXE" https://dist.nuget.org/win-x86-commandline/latest/nuget.exe - if [ $? -ne 0 ]; then - echo "An error occured while downloading nuget.exe." - exit 1 - fi -fi - -# Restore tools from NuGet. -pushd "$TOOLS_DIR" >/dev/null -if [ ! -f $PACKAGES_CONFIG_MD5 ] || [ "$( cat $PACKAGES_CONFIG_MD5 | sed 's/\r$//' )" != "$( $MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' )" ]; then - find . -type d ! -name . | xargs rm -rf -fi - -mono "$NUGET_EXE" install -ExcludeVersion -if [ $? -ne 0 ]; then - echo "Could not restore NuGet packages." - exit 1 -fi - -$MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' >| $PACKAGES_CONFIG_MD5 - -popd >/dev/null - -# Make sure that Cake has been installed. -if [ ! -f "$CAKE_EXE" ]; then - echo "Could not find Cake.exe at '$CAKE_EXE'." - exit 1 -fi - -# Start Cake -if $SHOW_VERSION; then - exec mono "$CAKE_EXE" -version -else - exec mono "$CAKE_EXE" $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}" -fi \ No newline at end of file +dotnet cake recipe.cake "$@" diff --git a/cake.config b/cake.config deleted file mode 100644 index 5c421deb..00000000 --- a/cake.config +++ /dev/null @@ -1,13 +0,0 @@ -; This is the default configuration file for Cake. -; This file was downloaded from https://github.com/cake-build/resources - -[Nuget] -Source=https://packages.nuget.org/api/v2 - -[Roslyn] -NuGetSource=https://packages.nuget.org/api/v2 - -[Paths] -Tools=./tools -Addins=./tools/Addins -Modules=./tools/Modules diff --git a/helpers.cake b/helpers.cake deleted file mode 100644 index ad7f7917..00000000 --- a/helpers.cake +++ /dev/null @@ -1,37 +0,0 @@ -List GetContent(IEnumerable frameworks, ProjectCollection projects, Func projectFilter = null) { - projectFilter = projectFilter ?? (p => true); - var content = new List(); - foreach (var framework in frameworks) { - foreach (var project in projects.SourceProjects.Where(projectFilter)) { - Verbose("Loading package files for " + project.Name); - var match = GetFiles(project.Path.GetDirectory() + "/bin/" + configuration + "/" + framework + "/" + project.Name +".*"); - var libFiles = match - .Where(f => f.GetExtension() != ".pdb") - .Where(f => !f.FullPath.Contains("Cake.Core")) - .Where(f => !f.FullPath.Contains("Cake.Common")) - .Select(f => new NuSpecContent { Source = f.FullPath, Target = "lib/" + framework}); - content.AddRange(libFiles); - } - } - return content; -} - -public class ProjectCollection { - public IEnumerable SourceProjects {get;set;} - public IEnumerable SourceProjectPaths {get { return SourceProjects.Select(p => p.Path.GetDirectory()); } } - public IEnumerable TestProjects {get;set;} - public IEnumerable TestProjectPaths { get { return TestProjects.Select(p => p.Path.GetDirectory()); } } - public IEnumerable AllProjects { get { return SourceProjects.Concat(TestProjects); } } - public IEnumerable AllProjectPaths { get { return AllProjects.Select(p => p.Path.GetDirectory()); } } -} - -ProjectCollection GetProjects(FilePath slnPath) { - var solution = ParseSolution(slnPath); - var projects = solution.Projects.Where(p => p.Type != "{2150E333-8FDC-42A3-9474-1A3956D46DE8}"); - var testAssemblies = projects.Where(p => p.Name.Contains(".Tests")).Select(p => p.Path.GetDirectory() + "/bin/" + configuration + "/" + p.Name + ".dll"); - return new ProjectCollection { - SourceProjects = projects.Where(p => !p.Name.Contains(".Tests")), - TestProjects = projects.Where(p => p.Name.Contains(".Tests")) - }; - -} \ No newline at end of file diff --git a/recipe.cake b/recipe.cake new file mode 100644 index 00000000..278ea7e9 --- /dev/null +++ b/recipe.cake @@ -0,0 +1,23 @@ +#load nuget:?package=Cake.Recipe&version=2.1.0 + +Environment.SetVariableNames(); + +var standardNotificationMessage = "Version {0} of {1} has just been released, this will be available here https://www.nuget.org/packages/{1}, once package indexing is complete."; + +BuildParameters.SetParameters( + context: Context, + buildSystem: BuildSystem, + sourceDirectoryPath: "./src", + title: "Cake.BuildSystems.Module", + repositoryOwner: "cake-contrib", + shouldRunDupFinder: false, // leave this out, for now. + shouldRunDotNetCorePack: true, + shouldUseDeterministicBuilds: true, + gitterMessage: "@/all " + standardNotificationMessage, + twitterMessage: standardNotificationMessage); + +BuildParameters.PrintParameters(Context); + +ToolSettings.SetToolSettings(context: Context); + +Build.RunDotNetCore(); diff --git a/src/Cake.AzurePipelines.Module/Cake.AzurePipelines.Module.csproj b/src/Cake.AzurePipelines.Module/Cake.AzurePipelines.Module.csproj index c5ec8520..cdb9202a 100644 --- a/src/Cake.AzurePipelines.Module/Cake.AzurePipelines.Module.csproj +++ b/src/Cake.AzurePipelines.Module/Cake.AzurePipelines.Module.csproj @@ -4,7 +4,7 @@ netstandard2.0 true Cake.AzurePipelines.Module - Cake.AzurePipelines.Module + false @@ -15,5 +15,4 @@ - diff --git a/src/Cake.BuildSystems.Module.sln b/src/Cake.BuildSystems.Module.sln index d71cecd1..8f3fdc7d 100644 --- a/src/Cake.BuildSystems.Module.sln +++ b/src/Cake.BuildSystems.Module.sln @@ -4,10 +4,8 @@ VisualStudioVersion = 15.0.26228.4 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CCCD79DB-5207-4116-905E-D3B85F24A9D7}" ProjectSection(SolutionItems) = preProject - ..\build.cake = ..\build.cake - ..\cake.config = ..\cake.config + ..\recipe.cake = ..\recipe.cake ..\README.md = ..\README.md - ..\ReleaseNotes.md = ..\ReleaseNotes.md EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cake.Module.Shared", "Cake.Module.Shared\Cake.Module.Shared.csproj", "{19079E09-A53C-4D38-ACC6-66DECAC59372}" @@ -20,6 +18,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.TravisCI.Module", "Cak EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.MyGet.Module", "Cake.MyGet.Module\Cake.MyGet.Module.csproj", "{CECFF9DB-D08C-4DA0-8C13-3CA523E1D116}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.BuildSystems.Module", "Cake.BuildSystems.Module\Cake.BuildSystems.Module.csproj", "{F9A7A095-162B-416D-9BBD-90EB447111EC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -86,6 +86,18 @@ Global {CECFF9DB-D08C-4DA0-8C13-3CA523E1D116}.Release|x64.Build.0 = Release|Any CPU {CECFF9DB-D08C-4DA0-8C13-3CA523E1D116}.Release|x86.ActiveCfg = Release|Any CPU {CECFF9DB-D08C-4DA0-8C13-3CA523E1D116}.Release|x86.Build.0 = Release|Any CPU + {F9A7A095-162B-416D-9BBD-90EB447111EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F9A7A095-162B-416D-9BBD-90EB447111EC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F9A7A095-162B-416D-9BBD-90EB447111EC}.Debug|x64.ActiveCfg = Debug|Any CPU + {F9A7A095-162B-416D-9BBD-90EB447111EC}.Debug|x64.Build.0 = Debug|Any CPU + {F9A7A095-162B-416D-9BBD-90EB447111EC}.Debug|x86.ActiveCfg = Debug|Any CPU + {F9A7A095-162B-416D-9BBD-90EB447111EC}.Debug|x86.Build.0 = Debug|Any CPU + {F9A7A095-162B-416D-9BBD-90EB447111EC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F9A7A095-162B-416D-9BBD-90EB447111EC}.Release|Any CPU.Build.0 = Release|Any CPU + {F9A7A095-162B-416D-9BBD-90EB447111EC}.Release|x64.ActiveCfg = Release|Any CPU + {F9A7A095-162B-416D-9BBD-90EB447111EC}.Release|x64.Build.0 = Release|Any CPU + {F9A7A095-162B-416D-9BBD-90EB447111EC}.Release|x86.ActiveCfg = Release|Any CPU + {F9A7A095-162B-416D-9BBD-90EB447111EC}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Cake.BuildSystems.Module/Cake.BuildSystems.Module.csproj b/src/Cake.BuildSystems.Module/Cake.BuildSystems.Module.csproj new file mode 100644 index 00000000..477519f2 --- /dev/null +++ b/src/Cake.BuildSystems.Module/Cake.BuildSystems.Module.csproj @@ -0,0 +1,59 @@ + + + + netstandard2.0 + false + true + + + + 2017 + $([System.DateTime]::Today.Year) + $(StartYear) + $(StartYear)-$(EndYear) + + + Cake Build Systems Module + Cake.BuildSystems.Module + 0.1.0 + Alistair Chapman + Copyright © Alistair Chapman $(FullYear) + 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/ + cake, build, ci + https://github.com/cake-contrib/Cake.BuildSystems.Module.git + git + https://cakeresources.blob.core.windows.net/nuget/64/deployment-64.png + + + + + all + + + all + + + all + + + all + + + + + + + + + + + + + + + + diff --git a/src/Cake.BuildSystems.Module/Readme.txt b/src/Cake.BuildSystems.Module/Readme.txt new file mode 100644 index 00000000..d765b3b7 --- /dev/null +++ b/src/Cake.BuildSystems.Module/Readme.txt @@ -0,0 +1,2 @@ +This project is only a "shim" - all it does is provide the shell to generate +a nuget-package (using csproj features and not using a nuspec) \ No newline at end of file diff --git a/src/Cake.Module.Shared/Cake.Module.Shared.csproj b/src/Cake.Module.Shared/Cake.Module.Shared.csproj index d90890e5..74f16868 100644 --- a/src/Cake.Module.Shared/Cake.Module.Shared.csproj +++ b/src/Cake.Module.Shared/Cake.Module.Shared.csproj @@ -4,13 +4,13 @@ netstandard2.0 true Cake.Module.Shared - Cake.Module.Shared false false false false false false + false diff --git a/src/Cake.Module.Shared/Properties/AssemblyInfo.cs b/src/Cake.Module.Shared/Properties/AssemblyInfo.cs deleted file mode 100644 index 5b66035e..00000000 --- a/src/Cake.Module.Shared/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("Cake.Module.Shared")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Cake.Module.Shared")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("A73F44AF-70FD-4101-B9B9-8104EE550C65")] \ No newline at end of file diff --git a/src/Cake.MyGet.Module/Cake.MyGet.Module.csproj b/src/Cake.MyGet.Module/Cake.MyGet.Module.csproj index db80f908..e153efa7 100644 --- a/src/Cake.MyGet.Module/Cake.MyGet.Module.csproj +++ b/src/Cake.MyGet.Module/Cake.MyGet.Module.csproj @@ -4,7 +4,7 @@ netstandard2.0 true Cake.MyGet.Module - Cake.MyGet.Module + false @@ -15,5 +15,4 @@ - diff --git a/src/Cake.TeamCity.Module/Cake.TeamCity.Module.csproj b/src/Cake.TeamCity.Module/Cake.TeamCity.Module.csproj index 5ee27a70..dde00336 100644 --- a/src/Cake.TeamCity.Module/Cake.TeamCity.Module.csproj +++ b/src/Cake.TeamCity.Module/Cake.TeamCity.Module.csproj @@ -4,7 +4,7 @@ netstandard2.0 true Cake.TeamCity.Module - Cake.TeamCity.Module + false @@ -15,5 +15,4 @@ - diff --git a/src/Cake.TravisCI.Module/Cake.TravisCI.Module.csproj b/src/Cake.TravisCI.Module/Cake.TravisCI.Module.csproj index 1837ccf8..3bf1a3e5 100644 --- a/src/Cake.TravisCI.Module/Cake.TravisCI.Module.csproj +++ b/src/Cake.TravisCI.Module/Cake.TravisCI.Module.csproj @@ -4,7 +4,7 @@ netstandard2.0 true Cake.TravisCI.Module - Cake.TravisCI.Module + false @@ -15,5 +15,4 @@ - diff --git a/tools/packages.config b/tools/packages.config deleted file mode 100644 index 218f0a47..00000000 --- a/tools/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - -