Skip to content

Commit 5588de3

Browse files
AldenAlden
Alden
authored and
Alden
committed
Continuous integration configuration
1 parent 26bc3c0 commit 5588de3

6 files changed

+378
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@
77
/src/Extendable/bin/Debug/netcoreapp2.0
88
/src/Extendable.Tests/bin/Debug/netcoreapp2.0
99
/src/Extendable.Tests/obj
10+
/src/Extendable/bin/Release/netcoreapp2.0
11+
/src/Extendable.Tests/bin/Release/netcoreapp2.0
12+
tools/**
13+
!tools/packages.config
14+
/.vs

Extendable.nuspec

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0"?>
2+
<package >
3+
<metadata>
4+
<id>Extendable</id>
5+
<!--<version>1.0.0</version>-->
6+
<authors>Alden Menzalgy</authors>
7+
<owners>Alden Menzalgy</owners>
8+
<licenseUrl>https://github.com/almez/Extendable/blob/master/LICENSE</licenseUrl>
9+
<projectUrl>https://github.com/almez/Extendable</projectUrl>
10+
<!--<iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl>-->
11+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
12+
<description>.NET Core 2.0 Introduce new fields to your types dynamically.</description>
13+
<releaseNotes>Initial Release</releaseNotes>
14+
<copyright>Copyright 2017</copyright>
15+
<tags>.NETCORE2.0 MemoryCache Cache</tags>
16+
<dependencies>
17+
<dependency id="Microsoft.Extensions.Caching.Memory" version="2.0.0" />
18+
</dependencies>
19+
</metadata>
20+
</package>

appveyor.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: 1.0.{build}
2+
image: Visual Studio 2017
3+
configuration: Release
4+
dotnet_csproj:
5+
patch: true
6+
file: '**\*.csproj'
7+
version: '{version}'
8+
package_version: '{version}'
9+
assembly_version: '{version}'
10+
file_version: '{version}'
11+
informational_version: '{version}'
12+
before_build:
13+
- ps: nuget restore '.\src\Extendable.sln'
14+
build:
15+
project: src\Extendable.sln
16+
parallel: true
17+
verbosity: minimal
18+
after_build:
19+
- cmd: PowerShell -Version 2.0 .\build.ps1
20+
test_script:
21+
- cmd: dotnet test "src\Extendable.Tests\Extendable.Tests.csproj" --configuration Release --no-build
22+
artifacts:
23+
- path: Extendable.*.nupkg
24+
name: Push to NuGet
25+
deploy:
26+
- provider: NuGet
27+
api_key:
28+
secure: YJ757SM9zR7PnGl+CWUHjcgPhsIDh3XNA04smLWWQr0YHbU+ADCr/heVgrO+Bzua
29+
skip_symbols: true
30+
artifact: /.*\.nupkg/

build.cake

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#tool nuget:?package=NUnit.ConsoleRunner&version=3.4.0
2+
//////////////////////////////////////////////////////////////////////
3+
// ARGUMENTS
4+
//////////////////////////////////////////////////////////////////////
5+
6+
var target = Argument("target", "Default");
7+
var configuration = Argument("configuration", "Release");
8+
9+
//////////////////////////////////////////////////////////////////////
10+
// PREPARATION
11+
//////////////////////////////////////////////////////////////////////
12+
13+
// Define directories.
14+
var buildDir = Directory("./src/Extendable/bin");
15+
16+
//////////////////////////////////////////////////////////////////////
17+
// TASKS
18+
//////////////////////////////////////////////////////////////////////
19+
20+
Task("Clean")
21+
.Does(() =>
22+
{
23+
CleanDirectory(buildDir);
24+
});
25+
26+
Task("Restore-NuGet-Packages")
27+
.IsDependentOn("Clean")
28+
.Does(() =>
29+
{
30+
NuGetRestore("./src/Extendable.sln");
31+
});
32+
33+
Task("Build")
34+
.IsDependentOn("Restore-NuGet-Packages")
35+
.Does(() =>
36+
{
37+
if(IsRunningOnWindows())
38+
{
39+
// Use MSBuild
40+
MSBuild("./src/Extendable.sln", settings =>
41+
settings.SetConfiguration(configuration));
42+
}
43+
else
44+
{
45+
// Use XBuild
46+
XBuild("./src/Extendable.sln", settings =>
47+
settings.SetConfiguration(configuration));
48+
}
49+
});
50+
51+
Task("Run-Unit-Tests")
52+
.IsDependentOn("Build")
53+
.Does(() =>
54+
{
55+
NUnit3("./**/bin/" + configuration + "/*.Tests.dll", new NUnit3Settings {
56+
NoResults = true
57+
});
58+
});
59+
60+
//////////////////////////////////////////////////////////////////////
61+
// PUSH NUGET PACKAGE
62+
//////////////////////////////////////////////////////////////////////
63+
64+
Task("Package")
65+
.IsDependentOn("Run-Unit-Tests")
66+
.Does(() => {
67+
68+
var buildNo = BuildSystem.AppVeyor.Environment.Build.Number;
69+
var buildVersion = BuildSystem.AppVeyor.Environment.Build.Version;
70+
var buildId = BuildSystem.AppVeyor.Environment.Build.Id;
71+
72+
NuGetPack("./Extendable.nuspec",
73+
new NuGetPackSettings() {
74+
Version = buildVersion,
75+
Files = new [] { new NuSpecContent {Source = "./src/Extendable/bin/Release/netcoreapp2.0/CachingManager.dll", Target = "lib/netcoreapp2.0"}, },
76+
});
77+
});
78+
79+
//////////////////////////////////////////////////////////////////////
80+
// TASK TARGETS
81+
//////////////////////////////////////////////////////////////////////
82+
83+
Task("Default")
84+
.IsDependentOn("Package");
85+
86+
//////////////////////////////////////////////////////////////////////
87+
// EXECUTION
88+
//////////////////////////////////////////////////////////////////////
89+
90+
RunTarget(target);

build.ps1

+229
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
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+
.SYNOPSIS
9+
This is a Powershell script to bootstrap a Cake build.
10+
.DESCRIPTION
11+
This Powershell script will download NuGet if missing, restore NuGet tools (including Cake)
12+
and execute your Cake build script with the parameters you provide.
13+
.PARAMETER Script
14+
The build script to execute.
15+
.PARAMETER Target
16+
The build script target to run.
17+
.PARAMETER Configuration
18+
The build configuration to use.
19+
.PARAMETER Verbosity
20+
Specifies the amount of information to be displayed.
21+
.PARAMETER ShowDescription
22+
Shows description about tasks.
23+
.PARAMETER DryRun
24+
Performs a dry run.
25+
.PARAMETER Experimental
26+
Uses the nightly builds of the Roslyn script engine.
27+
.PARAMETER Mono
28+
Uses the Mono Compiler rather than the Roslyn script engine.
29+
.PARAMETER SkipToolPackageRestore
30+
Skips restoring of packages.
31+
.PARAMETER ScriptArgs
32+
Remaining arguments are added here.
33+
.LINK
34+
https://cakebuild.net
35+
#>
36+
37+
[CmdletBinding()]
38+
Param(
39+
[string]$Script = "build.cake",
40+
[string]$Target,
41+
[string]$Configuration,
42+
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
43+
[string]$Verbosity,
44+
[switch]$ShowDescription,
45+
[Alias("WhatIf", "Noop")]
46+
[switch]$DryRun,
47+
[switch]$Experimental,
48+
[switch]$Mono,
49+
[switch]$SkipToolPackageRestore,
50+
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
51+
[string[]]$ScriptArgs
52+
)
53+
54+
[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
55+
function MD5HashFile([string] $filePath)
56+
{
57+
if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf))
58+
{
59+
return $null
60+
}
61+
62+
[System.IO.Stream] $file = $null;
63+
[System.Security.Cryptography.MD5] $md5 = $null;
64+
try
65+
{
66+
$md5 = [System.Security.Cryptography.MD5]::Create()
67+
$file = [System.IO.File]::OpenRead($filePath)
68+
return [System.BitConverter]::ToString($md5.ComputeHash($file))
69+
}
70+
finally
71+
{
72+
if ($file -ne $null)
73+
{
74+
$file.Dispose()
75+
}
76+
}
77+
}
78+
79+
function GetProxyEnabledWebClient
80+
{
81+
$wc = New-Object System.Net.WebClient
82+
$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
83+
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
84+
$wc.Proxy = $proxy
85+
return $wc
86+
}
87+
88+
Write-Host "Preparing to run build script..."
89+
90+
if(!$PSScriptRoot){
91+
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
92+
}
93+
94+
$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
95+
$ADDINS_DIR = Join-Path $TOOLS_DIR "Addins"
96+
$MODULES_DIR = Join-Path $TOOLS_DIR "Modules"
97+
$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
98+
$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe"
99+
$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
100+
$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config"
101+
$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum"
102+
$ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config"
103+
$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config"
104+
105+
# Make sure tools folder exists
106+
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
107+
Write-Verbose -Message "Creating tools directory..."
108+
New-Item -Path $TOOLS_DIR -Type directory | out-null
109+
}
110+
111+
# Make sure that packages.config exist.
112+
if (!(Test-Path $PACKAGES_CONFIG)) {
113+
Write-Verbose -Message "Downloading packages.config..."
114+
try {
115+
$wc = GetProxyEnabledWebClient
116+
$wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch {
117+
Throw "Could not download packages.config."
118+
}
119+
}
120+
121+
# Try find NuGet.exe in path if not exists
122+
if (!(Test-Path $NUGET_EXE)) {
123+
Write-Verbose -Message "Trying to find nuget.exe in PATH..."
124+
$existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) }
125+
$NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1
126+
if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) {
127+
Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)."
128+
$NUGET_EXE = $NUGET_EXE_IN_PATH.FullName
129+
}
130+
}
131+
132+
# Try download NuGet.exe if not exists
133+
if (!(Test-Path $NUGET_EXE)) {
134+
Write-Verbose -Message "Downloading NuGet.exe..."
135+
try {
136+
$wc = GetProxyEnabledWebClient
137+
$wc.DownloadFile($NUGET_URL, $NUGET_EXE)
138+
} catch {
139+
Throw "Could not download NuGet.exe."
140+
}
141+
}
142+
143+
# Save nuget.exe path to environment to be available to child processed
144+
$ENV:NUGET_EXE = $NUGET_EXE
145+
146+
# Restore tools from NuGet?
147+
if(-Not $SkipToolPackageRestore.IsPresent) {
148+
Push-Location
149+
Set-Location $TOOLS_DIR
150+
151+
# Check for changes in packages.config and remove installed tools if true.
152+
[string] $md5Hash = MD5HashFile($PACKAGES_CONFIG)
153+
if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
154+
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
155+
Write-Verbose -Message "Missing or changed package.config hash..."
156+
Remove-Item * -Recurse -Exclude packages.config,nuget.exe
157+
}
158+
159+
Write-Verbose -Message "Restoring tools from NuGet..."
160+
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
161+
162+
if ($LASTEXITCODE -ne 0) {
163+
Throw "An error occured while restoring NuGet tools."
164+
}
165+
else
166+
{
167+
$md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
168+
}
169+
Write-Verbose -Message ($NuGetOutput | out-string)
170+
171+
Pop-Location
172+
}
173+
174+
# Restore addins from NuGet
175+
if (Test-Path $ADDINS_PACKAGES_CONFIG) {
176+
Push-Location
177+
Set-Location $ADDINS_DIR
178+
179+
Write-Verbose -Message "Restoring addins from NuGet..."
180+
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""
181+
182+
if ($LASTEXITCODE -ne 0) {
183+
Throw "An error occured while restoring NuGet addins."
184+
}
185+
186+
Write-Verbose -Message ($NuGetOutput | out-string)
187+
188+
Pop-Location
189+
}
190+
191+
# Restore modules from NuGet
192+
if (Test-Path $MODULES_PACKAGES_CONFIG) {
193+
Push-Location
194+
Set-Location $MODULES_DIR
195+
196+
Write-Verbose -Message "Restoring modules from NuGet..."
197+
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""
198+
199+
if ($LASTEXITCODE -ne 0) {
200+
Throw "An error occured while restoring NuGet modules."
201+
}
202+
203+
Write-Verbose -Message ($NuGetOutput | out-string)
204+
205+
Pop-Location
206+
}
207+
208+
# Make sure that Cake has been installed.
209+
if (!(Test-Path $CAKE_EXE)) {
210+
Throw "Could not find Cake.exe at $CAKE_EXE"
211+
}
212+
213+
214+
215+
# Build Cake arguments
216+
$cakeArguments = @("$Script");
217+
if ($Target) { $cakeArguments += "-target=$Target" }
218+
if ($Configuration) { $cakeArguments += "-configuration=$Configuration" }
219+
if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" }
220+
if ($ShowDescription) { $cakeArguments += "-showdescription" }
221+
if ($DryRun) { $cakeArguments += "-dryrun" }
222+
if ($Experimental) { $cakeArguments += "-experimental" }
223+
if ($Mono) { $cakeArguments += "-mono" }
224+
$cakeArguments += $ScriptArgs
225+
226+
# Start Cake
227+
Write-Host "Running build script..."
228+
&$CAKE_EXE $cakeArguments
229+
exit $LASTEXITCODE

tools/packages.config

+4
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.23.0" />
4+
</packages>

0 commit comments

Comments
 (0)