Skip to content

Commit 25adbff

Browse files
committed
Added deployment scripts, moved some dependencies into netstandard1.5 only
1 parent d0748aa commit 25adbff

File tree

4 files changed

+264
-17
lines changed

4 files changed

+264
-17
lines changed

appveyor.deploy.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
assembly_info:
2+
patch: false
3+
4+
platform:
5+
- Any CPU
6+
7+
configuration:
8+
- Debug
9+
10+
build_script:
11+
- ps: ./deploy.ps1
12+
13+
test: off
14+
skip_non_tags: true

deploy.cake

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#addin "Cake.Json"
2+
3+
using System.Net;
4+
using System.Linq;
5+
6+
var target = Argument("target", "Default");
7+
8+
string Get(string url)
9+
{
10+
var assetsRequest = WebRequest.CreateHttp(url);
11+
assetsRequest.Method = "GET";
12+
assetsRequest.Accept = "application/vnd.github.v3+json";
13+
assetsRequest.UserAgent = "BuildScript";
14+
15+
using (var assetsResponse = assetsRequest.GetResponse())
16+
{
17+
var assetsStream = assetsResponse.GetResponseStream();
18+
var assetsReader = new StreamReader(assetsStream);
19+
var assetsBody = assetsReader.ReadToEnd();
20+
return assetsBody;
21+
}
22+
}
23+
24+
Task("EnsureRequirements")
25+
.Does(() =>
26+
{
27+
if (!AppVeyor.IsRunningOnAppVeyor)
28+
throw new Exception("Deployment should happen via appveyor");
29+
30+
var isTag =
31+
AppVeyor.Environment.Repository.Tag.IsTag &&
32+
!string.IsNullOrWhiteSpace(AppVeyor.Environment.Repository.Tag.Name);
33+
if (!isTag)
34+
throw new Exception("Deployment should happen from a published GitHub release");
35+
});
36+
37+
var tag = "";
38+
39+
Task("UpdateVersionInfo")
40+
.IsDependentOn("EnsureRequirements")
41+
.Does(() =>
42+
{
43+
tag = AppVeyor.Environment.Repository.Tag.Name;
44+
AppVeyor.UpdateBuildVersion(tag);
45+
});
46+
47+
Task("DownloadGitHubReleaseArtifacts")
48+
.IsDependentOn("UpdateVersionInfo")
49+
.Does(() =>
50+
{
51+
var assets_url = ParseJson(Get("https://api.github.com/repos/shouldly/shouldly/releases/tags/" + tag))
52+
.GetValue("assets_url").Value<string>();
53+
EnsureDirectoryExists("./releaseArtifacts");
54+
foreach(var asset in DeserializeJson<JArray>(Get(assets_url)))
55+
{
56+
DownloadFile(asset.Value<string>("browser_download_url"), "./releaseArtifacts/" + asset.Value<string>("name"));
57+
}
58+
});
59+
60+
Task("DeployNuget")
61+
.IsDependentOn("DownloadGitHubReleaseArtifacts")
62+
.Does(() =>
63+
{
64+
// Turns .artifacts file into a lookup
65+
var fileLookup = System.IO.File
66+
.ReadAllLines("./releaseArtifacts/artifacts")
67+
.Select(l => l.Split(':'))
68+
.ToDictionary(v => v[0], v => v[1]);
69+
70+
NuGetPush(
71+
"./releaseArtifacts/" + fileLookup["nuget"],
72+
new NuGetPushSettings {
73+
ApiKey = EnvironmentVariable("NuGetApiKey"),
74+
Source = "https://www.nuget.org/api/v2/package"
75+
});
76+
});
77+
78+
Task("Deploy")
79+
.IsDependentOn("DeployNuget");
80+
81+
Task("Default")
82+
.IsDependentOn("Deploy");
83+
84+
Task("Verify")
85+
.Does(() => {
86+
// Nothing, used to make sure the script compiles
87+
});
88+
89+
RunTarget(target);

deploy.ps1

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
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 = "deploy.cake",
44+
[string]$Target = "Default",
45+
[string]$Configuration = "Release",
46+
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
47+
[string]$Verbosity = "Verbose",
48+
[switch]$Experimental,
49+
[Alias("DryRun","Noop")]
50+
[switch]$WhatIf,
51+
[switch]$Mono,
52+
[switch]$SkipToolPackageRestore,
53+
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
54+
[string[]]$ScriptArgs
55+
)
56+
57+
Write-Host "Preparing to run build script..."
58+
59+
$PSScriptRoot = split-path -parent $MyInvocation.MyCommand.Definition;
60+
$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
61+
$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
62+
$NUGET_URL = "http://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
63+
$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe"
64+
$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config"
65+
66+
# Should we use mono?
67+
$UseMono = "";
68+
if($Mono.IsPresent) {
69+
Write-Verbose -Message "Using the Mono based scripting engine."
70+
$UseMono = "-mono"
71+
}
72+
73+
# Should we use the new Roslyn?
74+
$UseExperimental = "";
75+
if($Experimental.IsPresent -and !($Mono.IsPresent)) {
76+
Write-Verbose -Message "Using experimental version of Roslyn."
77+
$UseExperimental = "-experimental"
78+
}
79+
80+
# Is this a dry run?
81+
$UseDryRun = "";
82+
if($WhatIf.IsPresent) {
83+
$UseDryRun = "-dryrun"
84+
}
85+
86+
# Make sure tools folder exists
87+
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
88+
Write-Verbose -Message "Creating tools directory..."
89+
New-Item -Path $TOOLS_DIR -Type directory | out-null
90+
}
91+
92+
# Make sure that packages.config exist.
93+
if (!(Test-Path $PACKAGES_CONFIG)) {
94+
Write-Verbose -Message "Downloading packages.config..."
95+
try { Invoke-WebRequest -Uri http://cakebuild.net/download/bootstrapper/packages -OutFile $PACKAGES_CONFIG } catch {
96+
Throw "Could not download packages.config."
97+
}
98+
}
99+
100+
# Try find NuGet.exe in path if not exists
101+
if (!(Test-Path $NUGET_EXE)) {
102+
Write-Verbose -Message "Trying to find nuget.exe in PATH..."
103+
$existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_) }
104+
$NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1
105+
if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) {
106+
Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)."
107+
$NUGET_EXE = $NUGET_EXE_IN_PATH.FullName
108+
}
109+
}
110+
111+
# Try download NuGet.exe if not exists
112+
if (!(Test-Path $NUGET_EXE)) {
113+
Write-Verbose -Message "Downloading NuGet.exe..."
114+
try {
115+
(New-Object System.Net.WebClient).DownloadFile($NUGET_URL, $NUGET_EXE)
116+
} catch {
117+
Throw "Could not download NuGet.exe."
118+
}
119+
}
120+
121+
# Save nuget.exe path to environment to be available to child processed
122+
$ENV:NUGET_EXE = $NUGET_EXE
123+
124+
# Restore tools from NuGet?
125+
if(-Not $SkipToolPackageRestore.IsPresent) {
126+
Push-Location
127+
Set-Location $TOOLS_DIR
128+
Write-Verbose -Message "Restoring tools from NuGet..."
129+
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
130+
if ($LASTEXITCODE -ne 0) {
131+
Throw "An error occured while restoring NuGet tools."
132+
}
133+
Write-Verbose -Message ($NuGetOutput | out-string)
134+
Pop-Location
135+
}
136+
137+
# Make sure that Cake has been installed.
138+
if (!(Test-Path $CAKE_EXE)) {
139+
Throw "Could not find Cake.exe at $CAKE_EXE"
140+
}
141+
142+
# Start Cake
143+
Write-Host "Running build script..."
144+
Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs"
145+
exit $LASTEXITCODE

src/TestStack.BDDfy/project.json

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@
77
"embed": "**/Scripts/*.*"
88
},
99
"dependencies": {
10-
"NETStandard.Library": "1.6.0"
1110
},
1211

1312
"frameworks": {
1413
"net40": {
1514
"dependencies": {
1615

1716
},
18-
"frameworkAssemblies": {
19-
"System.Runtime.Serialization": "4.0.0.0",
20-
"System.Xml": "4.0.0.0"
21-
},
17+
"frameworkAssemblies": {
18+
"System.Runtime.Serialization": "4.0.0.0",
19+
"System.Xml": "4.0.0.0"
20+
},
2221
"buildOptions": {
2322
"define": [
2423
"APPDOMAIN",
@@ -28,18 +27,18 @@
2827
},
2928
"netstandard1.5": {
3029
"imports": "dnxcore50",
31-
"dependencies": {
32-
"System.Diagnostics.StackTrace": "4.0.1",
33-
"System.Linq.Expressions": "4.1.0",
34-
"System.Reflection": "4.1.0",
35-
"System.Reflection.TypeExtensions": "4.1.0",
36-
"System.Runtime.Extensions": "4.1.0",
37-
"System.Runtime.Loader": "4.0.0",
38-
"System.Runtime.Serialization.Json": "4.0.2",
39-
"System.Runtime.Serialization.Primitives": "4.1.1",
40-
"System.Text.Encoding": "4.0.11",
41-
"System.Threading.ThreadPool": "4.0.10"
42-
}
30+
"dependencies": {
31+
"NETStandard.Library": "1.6.0",
32+
"System.Linq.Expressions": "4.1.0",
33+
"System.Reflection": "4.1.0",
34+
"System.Reflection.TypeExtensions": "4.1.0",
35+
"System.Runtime.Extensions": "4.1.0",
36+
"System.Runtime.Loader": "4.0.0",
37+
"System.Runtime.Serialization.Json": "4.0.2",
38+
"System.Runtime.Serialization.Primitives": "4.1.1",
39+
"System.Text.Encoding": "4.0.11",
40+
"System.Threading.ThreadPool": "4.0.10"
41+
}
4342
}
4443
}
4544
}

0 commit comments

Comments
 (0)