Skip to content

Commit 3590f53

Browse files
Added starter appveyor build
1 parent d91dede commit 3590f53

File tree

8 files changed

+342
-10
lines changed

8 files changed

+342
-10
lines changed

.appveyor.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
image: Visual Studio 2017
2+
build_script:
3+
- ps: .\build.ps1
4+
test: off

.gitignore

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,10 @@ nuget.exe
2828
debugSettings.json
2929
buildlog
3030
/.vs
31-
*.lock.json
32-
/omnisharp*.tar.gz
33-
scripts/Omnisharp*
34-
.msbuild-*/
3531

3632
# NuGet
3733
*.nuget.targets
3834

3935
# Build folder
40-
.tools/
41-
.dotnet/
42-
43-
# VS Code
44-
/.vscode/settings.json
45-
/.vscode/launch.json
36+
tools/*/
37+
tools/packages.config.md5sum

build.cake

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
var target = Argument("target", "Default");
2+
var configuration = Argument("configuration", "Release");
3+
var artifacts = "./artifacts";
4+
5+
Task("Clean")
6+
.Does(() =>
7+
{
8+
EnsureDirectoryExists(artifacts);
9+
CleanDirectory(artifacts);
10+
});
11+
12+
Task("Restore")
13+
.Does(() =>
14+
{
15+
DotNetCoreRestore();
16+
});
17+
18+
Task("Build")
19+
.IsDependentOn("Restore")
20+
.Does(() =>
21+
{
22+
foreach (var project in GetFiles("**/*.csproj"))
23+
DotNetCoreBuild(project.FullPath);
24+
});
25+
26+
Task("Test")
27+
.IsDependentOn("Build")
28+
.Does(() =>
29+
{
30+
});
31+
32+
Task("Default")
33+
.IsDependentOn("Clean")
34+
.IsDependentOn("Build")
35+
.IsDependentOn("Test");
36+
37+
RunTarget(target);

build.ps1

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
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+
[parameter(position=0)]
44+
[string]$Target = "Default",
45+
[string]$Script = "build.cake",
46+
[ValidateSet("Release", "Debug")]
47+
[string]$Configuration = "Release",
48+
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
49+
[string]$Verbosity = "Verbose",
50+
[switch]$Experimental,
51+
[Alias("DryRun","Noop")]
52+
[switch]$WhatIf,
53+
[switch]$Mono,
54+
[switch]$SkipToolPackageRestore,
55+
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
56+
[string[]]$ScriptArgs
57+
)
58+
59+
[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
60+
function MD5HashFile([string] $filePath)
61+
{
62+
if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf))
63+
{
64+
return $null
65+
}
66+
67+
[System.IO.Stream] $file = $null;
68+
[System.Security.Cryptography.MD5] $md5 = $null;
69+
try
70+
{
71+
$md5 = [System.Security.Cryptography.MD5]::Create()
72+
$file = [System.IO.File]::OpenRead($filePath)
73+
return [System.BitConverter]::ToString($md5.ComputeHash($file))
74+
}
75+
finally
76+
{
77+
if ($file -ne $null)
78+
{
79+
$file.Dispose()
80+
}
81+
}
82+
}
83+
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+
# Should we use mono?
98+
$UseMono = "";
99+
if($Mono.IsPresent) {
100+
Write-Verbose -Message "Using the Mono based scripting engine."
101+
$UseMono = "-mono"
102+
}
103+
104+
# Should we use the new Roslyn?
105+
$UseExperimental = "";
106+
if($Experimental.IsPresent -and !($Mono.IsPresent)) {
107+
Write-Verbose -Message "Using experimental version of Roslyn."
108+
$UseExperimental = "-experimental"
109+
}
110+
111+
# Is this a dry run?
112+
$UseDryRun = "";
113+
if($WhatIf.IsPresent) {
114+
$UseDryRun = "-dryrun"
115+
}
116+
117+
# Make sure tools folder exists
118+
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
119+
Write-Verbose -Message "Creating tools directory..."
120+
New-Item -Path $TOOLS_DIR -Type directory | out-null
121+
}
122+
123+
# Make sure that packages.config exist.
124+
if (!(Test-Path $PACKAGES_CONFIG)) {
125+
Write-Verbose -Message "Downloading packages.config..."
126+
try { (New-Object System.Net.WebClient).DownloadFile("http://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch {
127+
Throw "Could not download packages.config."
128+
}
129+
}
130+
131+
# Try find NuGet.exe in path if not exists
132+
if (!(Test-Path $NUGET_EXE)) {
133+
Write-Verbose -Message "Trying to find nuget.exe in PATH..."
134+
$existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) }
135+
$NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1
136+
if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) {
137+
Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)."
138+
$NUGET_EXE = $NUGET_EXE_IN_PATH.FullName
139+
}
140+
}
141+
142+
# Try download NuGet.exe if not exists
143+
if (!(Test-Path $NUGET_EXE)) {
144+
Write-Verbose -Message "Downloading NuGet.exe..."
145+
try {
146+
(New-Object System.Net.WebClient).DownloadFile($NUGET_URL, $NUGET_EXE)
147+
} catch {
148+
Throw "Could not download NuGet.exe."
149+
}
150+
}
151+
152+
# Save nuget.exe path to environment to be available to child processed
153+
$ENV:NUGET_EXE = $NUGET_EXE
154+
155+
# Restore tools from NuGet?
156+
if(-Not $SkipToolPackageRestore.IsPresent) {
157+
Push-Location
158+
Set-Location $TOOLS_DIR
159+
160+
# Check for changes in packages.config and remove installed tools if true.
161+
[string] $md5Hash = MD5HashFile($PACKAGES_CONFIG)
162+
if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
163+
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
164+
Write-Verbose -Message "Missing or changed package.config hash..."
165+
Remove-Item * -Recurse -Exclude packages.config,nuget.exe
166+
}
167+
168+
Write-Verbose -Message "Restoring tools from NuGet..."
169+
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
170+
171+
if ($LASTEXITCODE -ne 0) {
172+
Throw "An error occured while restoring NuGet tools."
173+
}
174+
else
175+
{
176+
$md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
177+
}
178+
Write-Verbose -Message ($NuGetOutput | out-string)
179+
Pop-Location
180+
}
181+
182+
# Make sure that Cake has been installed.
183+
if (!(Test-Path $CAKE_EXE)) {
184+
Throw "Could not find Cake.exe at $CAKE_EXE"
185+
}
186+
187+
# Start Cake
188+
Write-Host "Running build script..."
189+
Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs"
190+
exit $LASTEXITCODE

build.sh

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/usr/bin/env bash
2+
3+
##########################################################################
4+
# This is the Cake bootstrapper script for Linux and OS X.
5+
# This file was downloaded from https://github.com/cake-build/resources
6+
# Feel free to change this file to fit your needs.
7+
##########################################################################
8+
9+
# Define directories.
10+
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
11+
TOOLS_DIR=$SCRIPT_DIR/tools
12+
NUGET_EXE=$TOOLS_DIR/nuget.exe
13+
CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe
14+
PACKAGES_CONFIG=$TOOLS_DIR/packages.config
15+
PACKAGES_CONFIG_MD5=$TOOLS_DIR/packages.config.md5sum
16+
17+
# Define md5sum or md5 depending on Linux/OSX
18+
MD5_EXE=
19+
if [[ "$(uname -s)" == "Darwin" ]]; then
20+
MD5_EXE="md5 -r"
21+
else
22+
MD5_EXE="md5sum"
23+
fi
24+
25+
# Define default arguments.
26+
SCRIPT="build.cake"
27+
TARGET="Default"
28+
CONFIGURATION="Release"
29+
VERBOSITY="verbose"
30+
DRYRUN=
31+
SHOW_VERSION=false
32+
SCRIPT_ARGUMENTS=()
33+
34+
# Parse arguments.
35+
for i in "$@"; do
36+
case $1 in
37+
-s|--script) SCRIPT="$2"; shift ;;
38+
-t|--target) TARGET="$2"; shift ;;
39+
-c|--configuration) CONFIGURATION="$2"; shift ;;
40+
-v|--verbosity) VERBOSITY="$2"; shift ;;
41+
-d|--dryrun) DRYRUN="-dryrun" ;;
42+
--version) SHOW_VERSION=true ;;
43+
--) shift; SCRIPT_ARGUMENTS+=("$@"); break ;;
44+
*) SCRIPT_ARGUMENTS+=("$1") ;;
45+
esac
46+
shift
47+
done
48+
49+
# Make sure the tools folder exist.
50+
if [ ! -d "$TOOLS_DIR" ]; then
51+
mkdir "$TOOLS_DIR"
52+
fi
53+
54+
# Make sure that packages.config exist.
55+
if [ ! -f "$TOOLS_DIR/packages.config" ]; then
56+
echo "Downloading packages.config..."
57+
curl -Lsfo "$TOOLS_DIR/packages.config" http://cakebuild.net/download/bootstrapper/packages
58+
if [ $? -ne 0 ]; then
59+
echo "An error occured while downloading packages.config."
60+
exit 1
61+
fi
62+
fi
63+
64+
# Download NuGet if it does not exist.
65+
if [ ! -f "$NUGET_EXE" ]; then
66+
echo "Downloading NuGet..."
67+
curl -Lsfo "$NUGET_EXE" https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
68+
if [ $? -ne 0 ]; then
69+
echo "An error occured while downloading nuget.exe."
70+
exit 1
71+
fi
72+
fi
73+
74+
# Restore tools from NuGet.
75+
pushd "$TOOLS_DIR" >/dev/null
76+
if [ ! -f $PACKAGES_CONFIG_MD5 ] || [ "$( cat $PACKAGES_CONFIG_MD5 | sed 's/\r$//' )" != "$( $MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' )" ]; then
77+
find . -type d ! -name . | xargs rm -rf
78+
fi
79+
80+
mono "$NUGET_EXE" install -ExcludeVersion
81+
if [ $? -ne 0 ]; then
82+
echo "Could not restore NuGet packages."
83+
exit 1
84+
fi
85+
86+
$MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' >| $PACKAGES_CONFIG_MD5
87+
88+
popd >/dev/null
89+
90+
# Make sure that Cake has been installed.
91+
if [ ! -f "$CAKE_EXE" ]; then
92+
echo "Could not find Cake.exe at '$CAKE_EXE'."
93+
exit 1
94+
fi
95+
96+
# Start Cake
97+
if $SHOW_VERSION; then
98+
exec mono "$CAKE_EXE" -version
99+
else
100+
exec mono "$CAKE_EXE" $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}"
101+
fi

tasks/variables.cake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var target = Argument("target", "Default");
2+
var configuration = Argument("configuration", "Release");
3+
var artifacts = "./artifacts";

tools/packages.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Cake" version="0.19.4" />
4+
</packages>

tools/packages.config.md5sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
02-CE-24-3B-5B-52-A7-60-24-0B-F1-E9-99-03-60-C2

0 commit comments

Comments
 (0)