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

Commit c00e09b

Browse files
Merge pull request #1 from thefringeninja/cake-build
Cake Build Script
2 parents a440cc0 + d3838ba commit c00e09b

11 files changed

Lines changed: 826 additions & 898 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,4 @@ paket-files/
250250
# JetBrains Rider
251251
.idea/
252252
*.sln.iml
253+
tools/**

build.cake

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#tool "nuget:?package=xunit.runner.console&version=2.1.0"
2+
3+
#addin "Cake.FileHelpers"
4+
5+
var target = Argument("target", "Default");
6+
var configuration = Argument("configuration", "Release");
7+
var artifactsDir = Directory("./artifacts");
8+
var srcDir = Directory("./src");
9+
var solution = srcDir + File("SqlStreamStore.HAL.sln");
10+
var buildNumber = string.IsNullOrWhiteSpace(EnvironmentVariable("BUILD_NUMBER")) ? "0" : EnvironmentVariable("BUILD_NUMBER");
11+
12+
Task("Clean")
13+
.Does(() =>
14+
{
15+
CleanDirectory(artifactsDir);
16+
});
17+
18+
Task("RestorePackages")
19+
.IsDependentOn("Clean")
20+
.Does(() =>
21+
{
22+
DotNetCoreRestore(solution);
23+
NuGetRestore(solution);
24+
});
25+
26+
Task("Build")
27+
.IsDependentOn("RestorePackages")
28+
.Does(() =>
29+
{
30+
DotNetCoreBuild(solution, new DotNetCoreBuildSettings {
31+
Configuration = configuration
32+
});
33+
});
34+
35+
Task("RunTests")
36+
.IsDependentOn("Build")
37+
.Does(() =>
38+
{
39+
40+
var testProjects = new string[] { "SqlStreamStore.HAL.Tests" };
41+
42+
foreach(var testProject in testProjects) {
43+
var projectDir = srcDir + Directory(testProject);
44+
StartProcess("dotnet", new ProcessSettings {
45+
Arguments = "xunit",
46+
WorkingDirectory = projectDir
47+
});
48+
}
49+
});
50+
51+
Task("NuGetPack")
52+
.IsDependentOn("Build")
53+
.Does(() =>
54+
{
55+
var versionSuffix = "build" + buildNumber.ToString().PadLeft(5, '0');
56+
57+
DotNetCorePack(srcDir + Directory("SqlStreamStore.HAL"), new DotNetCorePackSettings {
58+
ArgumentCustomization = args => args.Append("/p:Version=1.0.0-" + versionSuffix),
59+
OutputDirectory = artifactsDir,
60+
NoBuild = true,
61+
Configuration = configuration,
62+
VersionSuffix = versionSuffix
63+
});
64+
});
65+
66+
Task("Default")
67+
.IsDependentOn("RunTests")
68+
.IsDependentOn("NuGetPack");
69+
70+
RunTarget(target);

build.ps1

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<#
2+
.SYNOPSIS
3+
This is a Powershell script to bootstrap a Cake build.
4+
.DESCRIPTION
5+
This Powershell script will download NuGet if missing, restore NuGet tools (including Cake)
6+
and execute your Cake build script with the parameters you provide.
7+
.PARAMETER Target
8+
The build script target to run.
9+
.PARAMETER Configuration
10+
The build configuration to use.
11+
.PARAMETER Verbosity
12+
Specifies the amount of information to be displayed.
13+
.PARAMETER WhatIf
14+
Performs a dry run of the build script.
15+
No tasks will be executed.
16+
.PARAMETER ScriptArgs
17+
Remaining arguments are added here.
18+
.LINK
19+
http://cakebuild.net
20+
#>
21+
22+
[CmdletBinding()]
23+
Param(
24+
[string]$Target = "Default",
25+
[ValidateSet("Release", "Debug")]
26+
[string]$Configuration = "Release",
27+
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
28+
[string]$Verbosity = "Verbose",
29+
[switch]$WhatIf,
30+
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
31+
[string[]]$ScriptArgs
32+
)
33+
34+
$CakeVersion = "0.19.3"
35+
$DotNetChannel = "preview";
36+
$DotNetVersion = "1.0.3";
37+
$DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1";
38+
$NugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
39+
40+
# Make sure tools folder exists
41+
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
42+
$ToolPath = Join-Path $PSScriptRoot "tools"
43+
if (!(Test-Path $ToolPath)) {
44+
Write-Verbose "Creating tools directory..."
45+
New-Item -Path $ToolPath -Type directory | out-null
46+
}
47+
48+
###########################################################################
49+
# INSTALL .NET CORE CLI
50+
###########################################################################
51+
52+
Function Remove-PathVariable([string]$VariableToRemove)
53+
{
54+
$path = [Environment]::GetEnvironmentVariable("PATH", "User")
55+
if ($path -ne $null)
56+
{
57+
$newItems = $path.Split(';', [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove }
58+
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User")
59+
}
60+
61+
$path = [Environment]::GetEnvironmentVariable("PATH", "Process")
62+
if ($path -ne $null)
63+
{
64+
$newItems = $path.Split(';', [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove }
65+
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process")
66+
}
67+
}
68+
69+
# Get .NET Core CLI path if installed.
70+
$FoundDotNetCliVersion = $null;
71+
if (Get-Command dotnet -ErrorAction SilentlyContinue) {
72+
$FoundDotNetCliVersion = dotnet --version;
73+
}
74+
75+
if($FoundDotNetCliVersion -ne $DotNetVersion) {
76+
$InstallPath = Join-Path $PSScriptRoot ".dotnet"
77+
if (!(Test-Path $InstallPath)) {
78+
mkdir -Force $InstallPath | Out-Null;
79+
}
80+
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1");
81+
& $InstallPath\dotnet-install.ps1 -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath;
82+
83+
Remove-PathVariable "$InstallPath"
84+
$env:PATH = "$InstallPath;$env:PATH"
85+
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
86+
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1
87+
}
88+
89+
###########################################################################
90+
# INSTALL NUGET
91+
###########################################################################
92+
93+
# Make sure nuget.exe exists.
94+
$NugetPath = Join-Path $ToolPath "nuget.exe"
95+
if (!(Test-Path $NugetPath)) {
96+
Write-Host "Downloading NuGet.exe..."
97+
(New-Object System.Net.WebClient).DownloadFile($NugetUrl, $NugetPath);
98+
}
99+
100+
###########################################################################
101+
# INSTALL CAKE
102+
###########################################################################
103+
104+
# Make sure Cake has been installed.
105+
$CakePath = Join-Path $ToolPath "Cake.$CakeVersion/Cake.exe"
106+
if (!(Test-Path $CakePath)) {
107+
Write-Host "Installing Cake..."
108+
Invoke-Expression "&`"$NugetPath`" install Cake -Version $CakeVersion -OutputDirectory `"$ToolPath`"" | Out-Null;
109+
if ($LASTEXITCODE -ne 0) {
110+
Throw "An error occured while restoring Cake from NuGet."
111+
}
112+
}
113+
114+
###########################################################################
115+
# RUN BUILD SCRIPT
116+
###########################################################################
117+
118+
# Build the argument list.
119+
$Arguments = @{
120+
target=$Target;
121+
configuration=$Configuration;
122+
verbosity=$Verbosity;
123+
dryrun=$WhatIf;
124+
}.GetEnumerator() | %{"--{0}=`"{1}`"" -f $_.key, $_.value };
125+
126+
# Start Cake
127+
Write-Host "Running build script..."
128+
Invoke-Expression "& `"$CakePath`" `"build.cake`" $Arguments $ScriptArgs"
129+
exit $LASTEXITCODE

src/SqlStreamStore.HAL.Demo/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 15 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,24 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
1+
<Project Sdk="Microsoft.NET.Sdk">
42
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProjectGuid>{40942079-7C9C-4CC4-A8DA-A6643F03D82A}</ProjectGuid>
8-
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
9-
<OutputType>Exe</OutputType>
10-
<AppDesignerFolder>Properties</AppDesignerFolder>
11-
<RootNamespace>SqlStreamStore.HAL.Demo</RootNamespace>
3+
<TargetFrameworks>netcoreapp1.0</TargetFrameworks>
124
<AssemblyName>SqlStreamStore.HAL.Demo</AssemblyName>
13-
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
14-
<FileAlignment>512</FileAlignment>
15-
</PropertyGroup>
16-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17-
<PlatformTarget>AnyCPU</PlatformTarget>
5+
<PackageId>SqlStreamStore.HAL.Demo</PackageId>
6+
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
7+
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
8+
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
9+
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
10+
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
11+
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
12+
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
13+
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
1814
<DebugSymbols>true</DebugSymbols>
19-
<DebugType>full</DebugType>
20-
<Optimize>false</Optimize>
21-
<OutputPath>bin\Debug\</OutputPath>
22-
<DefineConstants>DEBUG;TRACE</DefineConstants>
23-
<ErrorReport>prompt</ErrorReport>
24-
<WarningLevel>4</WarningLevel>
25-
</PropertyGroup>
26-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27-
<PlatformTarget>AnyCPU</PlatformTarget>
28-
<DebugType>pdbonly</DebugType>
29-
<Optimize>true</Optimize>
30-
<OutputPath>bin\Release\</OutputPath>
31-
<DefineConstants>TRACE</DefineConstants>
32-
<ErrorReport>prompt</ErrorReport>
33-
<WarningLevel>4</WarningLevel>
15+
<RuntimeFrameworkVersion>1.0.4</RuntimeFrameworkVersion>
3416
</PropertyGroup>
3517
<ItemGroup>
36-
<Reference Include="Microsoft.Owin, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
37-
<HintPath>..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
38-
</Reference>
39-
<Reference Include="Nowin, Version=0.25.0.0, Culture=neutral, PublicKeyToken=null">
40-
<HintPath>..\packages\Nowin.0.25.0\lib\net45\Nowin.dll</HintPath>
41-
</Reference>
42-
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5">
43-
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
44-
</Reference>
45-
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10">
46-
<HintPath>..\packages\Serilog.2.4.0\lib\net46\Serilog.dll</HintPath>
47-
</Reference>
48-
<Reference Include="Serilog.Sinks.ColoredConsole, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10">
49-
<HintPath>..\packages\Serilog.Sinks.ColoredConsole.2.0.0\lib\net45\Serilog.Sinks.ColoredConsole.dll</HintPath>
50-
</Reference>
51-
<Reference Include="SqlStreamStore, Version=0.6.0.0, Culture=neutral, PublicKeyToken=null">
52-
<HintPath>..\packages\SqlStreamStore.0.7.1\lib\net46\SqlStreamStore.dll</HintPath>
53-
</Reference>
54-
<Reference Include="System" />
55-
<Reference Include="System.Core" />
56-
<Reference Include="System.Data" />
57-
</ItemGroup>
58-
<ItemGroup>
59-
<Compile Include="Program.cs" />
60-
<Compile Include="Properties\AssemblyInfo.cs" />
61-
<Compile Include="SeedData.cs" />
62-
</ItemGroup>
63-
<ItemGroup>
64-
<Content Include="packages.config" />
65-
</ItemGroup>
66-
<ItemGroup>
67-
<ProjectReference Include="..\SqlStreamStore.HAL\SqlStreamStore.HAL.csproj">
68-
<Project>{022329C2-F59B-4350-8242-003CE480CD84}</Project>
69-
<Name>SqlStreamStore.HAL</Name>
70-
</ProjectReference>
18+
<ProjectReference Include="..\SqlStreamStore.HAL\SqlStreamStore.HAL.csproj" />
7119
</ItemGroup>
7220
<ItemGroup>
73-
<None Include="packages.config" />
21+
<PackageReference Include="Serilog" Version="2.4.0" />
22+
<PackageReference Include="Serilog.Sinks.ColoredConsole" Version="2.0.0" />
7423
</ItemGroup>
75-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
76-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
77-
Other similar extension points exist, see Microsoft.Common.targets.
78-
<Target Name="BeforeBuild">
79-
</Target>
80-
<Target Name="AfterBuild">
81-
</Target>
82-
-->
8324
</Project>

src/SqlStreamStore.HAL.Tests/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
// associated with an assembly.
77

88
[assembly: AssemblyTitle("SqlStreamStore.HAL.Tests")]
9-
[assembly: AssemblyDescription("")]
10-
[assembly: AssemblyConfiguration("")]
119
[assembly: AssemblyCompany("")]
1210
[assembly: AssemblyProduct("SqlStreamStore.HAL.Tests")]
1311
[assembly: AssemblyCopyright("Copyright © 2017")]

0 commit comments

Comments
 (0)