Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 4590354

Browse files
Merge pull request #7 from thefringeninja/fsm
Minor Improvements
2 parents 1958746 + 61863ac commit 4590354

50 files changed

Lines changed: 1819 additions & 865 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017-2018 João P. Bragança
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

build.cake

Lines changed: 17 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#addin "Cake.FileHelpers"
2-
#addin "Cake.Powershell"
1+
#addin "nuget:?package=Cake.FileHelpers&version=2.0.0"
32

43
var target = Argument("target", "Default");
54
var configuration = Argument("configuration", "Release");
@@ -19,7 +18,6 @@ Task("RestorePackages")
1918
.Does(() =>
2019
{
2120
DotNetCoreRestore(solution, new DotNetCoreRestoreSettings {
22-
EnvironmentVariables = DotNetEnvironment
2321
});
2422
});
2523

@@ -28,8 +26,7 @@ Task("Build")
2826
.Does(() =>
2927
{
3028
DotNetCoreBuild(solution, new DotNetCoreBuildSettings {
31-
Configuration = configuration,
32-
EnvironmentVariables = DotNetEnvironment
29+
Configuration = configuration
3330
});
3431
});
3532

@@ -42,108 +39,39 @@ Task("RunTests")
4239
foreach(var testProject in testProjects) {
4340
var projectDir = srcDir + Directory(testProject);
4441
StartProcess("dotnet", new ProcessSettings {
45-
Arguments = "xunit",
46-
WorkingDirectory = projectDir,
47-
EnvironmentVariables = DotNetEnvironment
42+
Arguments = $"xunit -quiet -parallel all -configuration {configuration} -nobuild",
43+
WorkingDirectory = projectDir
4844
});
4945
}
5046
});
5147

48+
Task("Publish")
49+
.IsDependentOn("Build")
50+
.Does(() =>
51+
{
52+
DotNetCorePublish(srcDir + Directory("SqlStreamStore.HAL"), new DotNetCorePublishSettings {
53+
OutputDirectory = artifactsDir,
54+
Configuration = configuration,
55+
Framework = "netstandard2.0"
56+
});
57+
});
58+
5259
Task("NuGetPack")
5360
.IsDependentOn("Build")
5461
.Does(() =>
5562
{
5663
var versionSuffix = "build" + buildNumber.ToString().PadLeft(5, '0');
5764

5865
DotNetCorePack(srcDir + Directory("SqlStreamStore.HAL"), new DotNetCorePackSettings {
59-
ArgumentCustomization = args => args.Append("/p:Version=1.0.0-" + versionSuffix),
6066
OutputDirectory = artifactsDir,
6167
NoBuild = true,
6268
Configuration = configuration,
63-
VersionSuffix = versionSuffix,
64-
EnvironmentVariables = DotNetEnvironment
69+
VersionSuffix = versionSuffix
6570
});
6671
});
6772

6873
Task("Default")
6974
.IsDependentOn("RunTests")
7075
.IsDependentOn("NuGetPack");
7176

72-
RunTarget(target);
73-
74-
Dictionary<string, string> DotNetEnvironment => new Dictionary<string, string> {
75-
{"PATH", Path}
76-
};
77-
78-
private string _path;
79-
80-
string Path => _path ?? (_path = DownloadDotNetCoreIfNecessary());
81-
82-
string DownloadDotNetCoreIfNecessary() {
83-
var path = Context.Environment.GetEnvironmentVariable("PATH");
84-
var version = "2.0.0";
85-
86-
if (DotNetVersion == System.Version.Parse(version)) {
87-
return path;
88-
}
89-
90-
var dotnetDirectory = Directory(".dotnet");
91-
92-
EnsureDirectoryExists(dotnetDirectory);
93-
94-
if (IsRunningOnWindows()) {
95-
DownloadDotNetCoreForWindows(dotnetDirectory, version);
96-
} else {
97-
DownloadDotNetCoreForUnix(dotnetDirectory, version);
98-
}
99-
return $"{dotnetDirectory.Path.MakeAbsolute(Context.Environment)};{path}";
100-
}
101-
102-
void DownloadDotNetCoreForWindows(ConvertableDirectoryPath dotnetDirectory, string version) {
103-
var channel = "Current";
104-
var installer = "https://dot.net/dotnet-install.ps1";
105-
var installerPath = dotnetDirectory + File("dotnet-install.ps1");
106-
107-
Information(installerPath);
108-
109-
DownloadFile(installer, installerPath);
110-
111-
StartPowershellFile(installerPath, args => {
112-
args.Append("Channel", channel);
113-
args.Append("Version", version);
114-
args.Append("InstallDir", dotnetDirectory);
115-
});
116-
}
117-
118-
void DownloadDotNetCoreForUnix(DirectoryPath dotnetDirectory, string version) {
119-
var channel = "Current";
120-
var installer = "https://dot.net/dotnet-install.sh";
121-
var installerPath = dotnetDirectory + File("dotnet-install.sh");
122-
123-
DownloadFile(installer, installerPath);
124-
125-
using (var process = StartAndReturnProcess(installerPath, new ProcessSettings {
126-
Arguments = $"--channel {channel} --version {version} --install-dir {dotnetDirectory}"
127-
})) {
128-
process.WaitForExit();
129-
}
130-
}
131-
132-
Version DotNetVersion {
133-
get {
134-
using (var process = StartAndReturnProcess("dotnet", new ProcessSettings {
135-
Arguments = "--version",
136-
RedirectStandardOutput = true
137-
})) {
138-
process.WaitForExit();
139-
140-
var stdout = process.GetStandardOutput().FirstOrDefault();
141-
142-
System.Version installedVersion;
143-
144-
System.Version.TryParse(stdout, out installedVersion);
145-
146-
return installedVersion;
147-
}
148-
}
149-
}
77+
RunTarget(target);

build.ps1

Lines changed: 90 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@ This is a Powershell script to bootstrap a Cake build.
44
.DESCRIPTION
55
This Powershell script will download NuGet if missing, restore NuGet tools (including Cake)
66
and execute your Cake build script with the parameters you provide.
7+
8+
.PARAMETER Script
9+
The build script to execute.
710
.PARAMETER Target
811
The build script target to run.
912
.PARAMETER Configuration
1013
The build configuration to use.
1114
.PARAMETER Verbosity
1215
Specifies the amount of information to be displayed.
16+
.PARAMETER Experimental
17+
Tells Cake to use the latest Roslyn release.
1318
.PARAMETER WhatIf
1419
Performs a dry run of the build script.
1520
No tasks will be executed.
@@ -21,65 +26,113 @@ http://cakebuild.net
2126

2227
[CmdletBinding()]
2328
Param(
29+
[string]$Script = "build.cake",
2430
[string]$Target = "Default",
2531
[ValidateSet("Release", "Debug")]
2632
[string]$Configuration = "Release",
2733
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
2834
[string]$Verbosity = "Verbose",
35+
[switch]$Experimental,
36+
[Alias("DryRun","Noop")]
2937
[switch]$WhatIf,
3038
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
3139
[string[]]$ScriptArgs
3240
)
3341

34-
$CakeVersion = "0.22.0"
35-
$NugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
42+
$cakeVersion = "0.26.0"
43+
$buildPath = "$PSScriptRoot/build"
44+
$proj = @"
45+
<Project Sdk="Microsoft.NET.Sdk">
46+
<PropertyGroup>
47+
<TargetFramework>netcoreapp2.0</TargetFramework>
48+
</PropertyGroup>
49+
<ItemGroup>
50+
<PackageReference Include="Cake.CoreCLR" Version="$cakeVersion" />
51+
</ItemGroup>
52+
</Project>
53+
"@
54+
55+
##########################
56+
# Install .NET Core CLI
57+
##########################
58+
$dotNetCoreVersion = "2.0.0"
59+
$dotNetInstallerUri = "https://dot.net/dotnet-install.ps1"
60+
Function Remove-PathVariable([string]$variableToRemove)
61+
{
62+
$path = [Environment]::GetEnvironmentVariable("PATH", "User")
63+
if ($path -ne $null)
64+
{
65+
$newItems = $path.Split(';', [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $variableToRemove }
66+
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User")
67+
}
3668

37-
# Make sure tools folder exists
38-
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
39-
$ToolPath = Join-Path $PSScriptRoot "tools"
40-
if (!(Test-Path $ToolPath)) {
41-
Write-Verbose "Creating tools directory..."
42-
New-Item -Path $ToolPath -Type directory | out-null
69+
$path = [Environment]::GetEnvironmentVariable("PATH", "Process")
70+
if ($path -ne $null)
71+
{
72+
$newItems = $path.Split(';', [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $variableToRemove }
73+
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process")
74+
}
4375
}
4476

45-
###########################################################################
46-
# INSTALL NUGET
47-
###########################################################################
77+
$installPath = Join-Path $PSScriptRoot ".dotnet"
78+
if (!(Test-Path $installPath)) {
79+
mkdir -Force $installPath | Out-Null;
80+
}
81+
(New-Object System.Net.WebClient).DownloadFile($dotNetInstallerUri, "$installPath\dotnet-install.ps1");
4882

49-
# Make sure nuget.exe exists.
50-
$NugetPath = Join-Path $ToolPath "nuget.exe"
51-
if (!(Test-Path $NugetPath)) {
52-
Write-Host "Downloading NuGet.exe..."
53-
(New-Object System.Net.WebClient).DownloadFile($NugetUrl, $NugetPath);
83+
$foundDotNetCliVersion = $null;
84+
if (Get-Command dotnet -ErrorAction SilentlyContinue) {
85+
$foundDotNetCliVersion = dotnet --version;
5486
}
87+
if($foundDotNetCliVersion -eq $dotNetCoreVersion) {
88+
Write-Host ".Net Core version $dotNetCoreVersion installed locally."
89+
}
90+
else {
91+
Write-Host ".Net Core version $dotNetCoreVersion not installated locally. Downloading..."
5592

56-
###########################################################################
57-
# INSTALL CAKE
58-
###########################################################################
59-
60-
# Make sure Cake has been installed.
61-
$CakePath = Join-Path $ToolPath "Cake.$CakeVersion/Cake.exe"
62-
if (!(Test-Path $CakePath)) {
63-
Write-Host "Installing Cake..."
64-
Invoke-Expression "&`"$NugetPath`" install Cake -Version $CakeVersion -OutputDirectory `"$ToolPath`"" | Out-Null;
65-
if ($LASTEXITCODE -ne 0) {
66-
Throw "An error occured while restoring Cake from NuGet."
67-
}
93+
& $installPath\dotnet-install.ps1 -Channel Current -Version $dotNetCoreVersion -InstallDir $installPath;
94+
95+
Remove-PathVariable "$installPath"
96+
$env:PATH = "$installPath;$env:PATH"
97+
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
98+
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1
99+
}
100+
101+
##########################
102+
# Install Cake
103+
##########################
104+
105+
Write-Host "Preparing cake..."
106+
# Make sure tools folder exists*
107+
$toolsPath = Join-Path $PSScriptRoot "tools"
108+
if (!(Test-Path $toolsPath)) {
109+
Write-Host "Creating tools directory..."
110+
New-Item -Path $toolsPath -Type directory | out-null
68111
}
112+
$proj | Out-File $toolsPath\cake.csproj
113+
114+
Push-Location $toolsPath
69115

70-
###########################################################################
71-
# RUN BUILD SCRIPT
72-
###########################################################################
116+
dotnet restore --packages ./
73117

74-
# Build the argument list.
75-
$Arguments = @{
118+
Pop-Location
119+
120+
##########################
121+
# Run buildscript
122+
##########################
123+
Write-Host "Running build script..."
124+
$arguments = @{
76125
target=$Target;
77126
configuration=$Configuration;
78127
verbosity=$Verbosity;
79128
dryrun=$WhatIf;
129+
NuGet_UseInProcessClient=$true;
80130
}.GetEnumerator() | %{"--{0}=`"{1}`"" -f $_.key, $_.value };
81131

82-
# Start Cake
83-
Write-Host "Running build script..."
84-
Invoke-Expression "& `"$CakePath`" `"build.cake`" $Arguments $ScriptArgs"
85-
exit $LASTEXITCODE
132+
Write-Host $toolsPath/cake.coreclr/$cakeVersion/Cake.dll $Script $arguments $ScriptArgs
133+
134+
$env:CAKE_SETTINGS_SKIPVERIFICATION=$true
135+
136+
&dotnet $toolsPath/cake.coreclr/$cakeVersion/Cake.dll $Script $arguments $ScriptArgs
137+
138+
exit $LASTEXITCODE

build.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
##########################################################################
3+
# This is the Cake bootstrapper script for Linux and OS X.
4+
# This file was downloaded from https://github.com/cake-build/resources
5+
# Feel free to change this file to fit your needs.
6+
##########################################################################
7+
8+
# Define directories.
9+
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
10+
TOOLS_DIR=$SCRIPT_DIR/tools
11+
TOOLS_PROJ=$TOOLS_DIR/tools.csproj
12+
CAKE_VERSION=0.26.1
13+
CAKE_DLL=$TOOLS_DIR/Cake.CoreCLR.$CAKE_VERSION/cake.coreclr/$CAKE_VERSION/Cake.dll
14+
DOTNET_INSTALL_PATH=$SCRIPT_DIR/.dotnet
15+
16+
# Make sure the tools folder exist.
17+
if [ ! -d "$TOOLS_DIR" ]; then
18+
mkdir "$TOOLS_DIR"
19+
fi
20+
21+
###########################################################################
22+
# Install .NET Core CLI
23+
###########################################################################
24+
curl -sSL https://dot.net/dotnet-install.sh | bash /dev/stdin --channel current --version 2.0.0 --install-dir $DOTNET_INSTALL_PATH
25+
26+
###########################################################################
27+
# INSTALL CAKE
28+
###########################################################################
29+
if [ ! -f "$CAKE_DLL" ]; then
30+
echo "<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><TargetFramework>netcoreapp2.0</TargetFramework></PropertyGroup></Project>" > $TOOLS_PROJ
31+
dotnet add $TOOLS_PROJ package cake.coreclr -v $CAKE_VERSION --package-directory $TOOLS_DIR/Cake.CoreCLR.$CAKE_VERSION
32+
fi
33+
34+
# Make sure that Cake has been installed.
35+
if [ ! -f "$CAKE_DLL" ]; then
36+
echo "Could not find Cake.exe at '$CAKE_DLL'."
37+
exit 1
38+
fi
39+
40+
###########################################################################
41+
# RUN BUILD SCRIPT
42+
###########################################################################
43+
44+
# Start Cake
45+
CAKE_SETTINGS_SKIPVERIFICATION=true exec dotnet "$CAKE_DLL" "$@"

0 commit comments

Comments
 (0)