Skip to content

Commit 6dc0aba

Browse files
committed
Switches to Cake.CoreClr and bumps Wyam version
1 parent 3b142b9 commit 6dc0aba

File tree

6 files changed

+60
-307
lines changed

6 files changed

+60
-307
lines changed

build.cake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// The following environment variables need to be set for Publish target:
22
// WYAM_GITHUB_TOKEN
33

4-
#tool "nuget:https://api.nuget.org/v3/index.json?package=Wyam&version=1.4.1"
5-
#addin "nuget:https://api.nuget.org/v3/index.json?package=Cake.Wyam&version=1.4.1"
4+
#tool "nuget:https://api.nuget.org/v3/index.json?package=Wyam&version=1.5.1"
5+
#addin "nuget:https://api.nuget.org/v3/index.json?package=Cake.Wyam&version=1.5.1"
66
#addin "nuget:https://api.nuget.org/v3/index.json?package=Octokit"
77

88
using Octokit;
@@ -153,7 +153,7 @@ Task("Debug")
153153
.Does(() =>
154154
{
155155
StartProcess("../Wyam/src/clients/Wyam/bin/Debug/net462/wyam.exe",
156-
"-a \"../Wyam/tests/integration/Wyam.Examples.Tests/bin/Debug/net462/**/*.dll\" -r \"docs -i\" -t \"../Wyam/themes/Docs/Samson\" -p -w");
156+
"-a \"../Wyam/tests/integration/Wyam.Examples.Tests/bin/Debug/net462/**/*.dll\" -r \"docs -i\" -t \"../Wyam/themes/Docs/Samson\" -p");
157157
});
158158

159159
Task("Deploy")

build.ps1

Lines changed: 25 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -1,194 +1,36 @@
1-
##########################################################################
2-
# This is the Cake bootstrapper script for PowerShell.
3-
# This file was downloaded from https://github.com/cake-build/resources
4-
# Feel free to change this file to fit your needs.
5-
##########################################################################
6-
7-
<#
8-
9-
.SYNOPSIS
10-
This is a Powershell script to bootstrap a Cake build.
11-
12-
.DESCRIPTION
13-
This Powershell script will download NuGet if missing, restore NuGet tools (including Cake)
14-
and execute your Cake build script with the parameters you provide.
15-
16-
.PARAMETER Script
17-
The build script to execute.
18-
.PARAMETER Target
19-
The build script target to run.
20-
.PARAMETER Configuration
21-
The build configuration to use.
22-
.PARAMETER Verbosity
23-
Specifies the amount of information to be displayed.
24-
.PARAMETER Experimental
25-
Tells Cake to use the latest Roslyn release.
26-
.PARAMETER WhatIf
27-
Performs a dry run of the build script.
28-
No tasks will be executed.
29-
.PARAMETER Mono
30-
Tells Cake to use the Mono scripting engine.
31-
.PARAMETER SkipToolPackageRestore
32-
Skips restoring of packages.
33-
.PARAMETER ScriptArgs
34-
Remaining arguments are added here.
35-
36-
.LINK
37-
http://cakebuild.net
38-
39-
#>
40-
41-
[CmdletBinding()]
42-
Param(
43-
[string]$Script = "build.cake",
44-
[string]$Target = "Default",
45-
[ValidateSet("Release", "Debug")]
46-
[string]$Configuration = "Release",
47-
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
48-
[string]$Verbosity = "Verbose",
49-
[switch]$Experimental,
50-
[Alias("DryRun","Noop")]
51-
[switch]$WhatIf,
52-
[switch]$Mono,
53-
[switch]$SkipToolPackageRestore,
54-
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
55-
[string[]]$ScriptArgs
1+
Param
2+
(
3+
[String]$CakeVersion = "0.30.0",
4+
[String]$ToolsDir = "$PSScriptRoot\tools",
5+
[String]$ToolsProj = "$ToolsDir\build.csproj",
6+
[String]$Script = "$PSScriptRoot\build.cake",
7+
[String]$Target = 'Default',
8+
[String]$Verbosity = 'normal'
569
)
5710

58-
[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
59-
function MD5HashFile([string] $filePath)
60-
{
61-
if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf))
62-
{
63-
return $null
64-
}
65-
66-
[System.IO.Stream] $file = $null;
67-
[System.Security.Cryptography.MD5] $md5 = $null;
68-
try
69-
{
70-
$md5 = [System.Security.Cryptography.MD5]::Create()
71-
$file = [System.IO.File]::OpenRead($filePath)
72-
return [System.BitConverter]::ToString($md5.ComputeHash($file))
73-
}
74-
finally
75-
{
76-
if ($file -ne $null)
77-
{
78-
$file.Dispose()
79-
}
80-
}
81-
}
82-
83-
$VerbosePreference = "continue"
84-
Write-Host "Preparing to run build script..."
85-
86-
if(!$PSScriptRoot){
87-
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
88-
}
89-
90-
$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
91-
$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
92-
$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe"
93-
$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
94-
$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config"
95-
$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum"
96-
97-
# Delete the Wyam tool and addin folders
98-
Remove-Item $TOOLS_DIR\Wyam* -Force -Recurse -ErrorAction Ignore
99-
Remove-Item $TOOLS_DIR\Addins\Cake.Wyam* -Force -Recurse -ErrorAction Ignore
100-
101-
# Should we use mono?
102-
$UseMono = "";
103-
if($Mono.IsPresent) {
104-
Write-Verbose -Message "Using the Mono based scripting engine."
105-
$UseMono = "-mono"
106-
}
107-
108-
# Should we use the new Roslyn?
109-
$UseExperimental = "";
110-
if($Experimental.IsPresent -and !($Mono.IsPresent)) {
111-
Write-Verbose -Message "Using experimental version of Roslyn."
112-
$UseExperimental = "-experimental"
113-
}
11+
$CAKE_DIR = "$ToolsDir\Cake.CoreCLR.$CakeVersion"
12+
$CAKE_DLL = "$CAKE_DIR\cake.coreclr\$CakeVersion\Cake.dll"
11413

115-
# Is this a dry run?
116-
$UseDryRun = "";
117-
if($WhatIf.IsPresent) {
118-
$UseDryRun = "-dryrun"
119-
}
120-
121-
# Make sure tools folder exists
122-
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
123-
Write-Verbose -Message "Creating tools directory..."
124-
New-Item -Path $TOOLS_DIR -Type directory | out-null
125-
}
126-
127-
# Make sure that packages.config exist.
128-
if (!(Test-Path $PACKAGES_CONFIG)) {
129-
Write-Verbose -Message "Downloading packages.config..."
130-
try { (New-Object System.Net.WebClient).DownloadFile("http://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch {
131-
Throw "Could not download packages.config."
132-
}
133-
}
134-
135-
# Try find NuGet.exe in path if not exists
136-
if (!(Test-Path $NUGET_EXE)) {
137-
Write-Verbose -Message "Trying to find nuget.exe in PATH..."
138-
$existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_) }
139-
$NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1
140-
if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) {
141-
Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)."
142-
$NUGET_EXE = $NUGET_EXE_IN_PATH.FullName
143-
}
14+
If (!(Test-Path $ToolsDir))
15+
{
16+
New-Item -ItemType Directory -Force -Path $ToolsDir
14417
}
14518

146-
# Try download NuGet.exe if not exists
147-
if (!(Test-Path $NUGET_EXE)) {
148-
Write-Verbose -Message "Downloading NuGet.exe..."
149-
try {
150-
(New-Object System.Net.WebClient).DownloadFile($NUGET_URL, $NUGET_EXE)
151-
} catch {
152-
Throw "Could not download NuGet.exe."
153-
}
19+
if (!(Test-Path $ToolsProj))
20+
{
21+
$projectFileContents = '<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>netcoreapp2.0</TargetFramework></PropertyGroup></Project>'
22+
Out-File -InputObject $projectFileContents -FilePath $ToolsProj
15423
}
15524

156-
# Save nuget.exe path to environment to be available to child processed
157-
$ENV:NUGET_EXE = $NUGET_EXE
158-
159-
# Restore tools from NuGet?
160-
if(-Not $SkipToolPackageRestore.IsPresent) {
161-
Push-Location
162-
Set-Location $TOOLS_DIR
163-
164-
# Check for changes in packages.config and remove installed tools if true.
165-
[string] $md5Hash = MD5HashFile($PACKAGES_CONFIG)
166-
if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
167-
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
168-
Write-Verbose -Message "Missing or changed package.config hash..."
169-
Remove-Item * -Recurse -Exclude packages.config,nuget.exe
170-
}
171-
172-
Write-Verbose -Message "Restoring tools from NuGet..."
173-
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
174-
175-
if ($LASTEXITCODE -ne 0) {
176-
Throw "An error occured while restoring NuGet tools."
177-
}
178-
else
179-
{
180-
$md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
181-
}
182-
Write-Verbose -Message ($NuGetOutput | out-string)
183-
Pop-Location
25+
dotnet add "$ToolsProj" package cake.coreclr -v "$CakeVersion" --package-directory "$CAKE_DIR"
26+
27+
if (!(Test-Path $CAKE_DLL))
28+
{
29+
Write-Error "Could not find Cake assembly '$CAKE_DLL'"
18430
}
185-
186-
# Make sure that Cake has been installed.
187-
if (!(Test-Path $CAKE_EXE)) {
188-
Throw "Could not find Cake.exe at $CAKE_EXE"
31+
else
32+
{
33+
dotnet "$CAKE_DLL" "$Script" --target="$Target" --verbosity="$Verbosity"
18934
}
19035

191-
# Start Cake
192-
Write-Host "Running build script..."
193-
Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs"
19436
exit $LASTEXITCODE

build.sh

Lines changed: 0 additions & 101 deletions
This file was deleted.

0 commit comments

Comments
 (0)