Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dbe5eeb

Browse files
authoredApr 1, 2018
v1.0.0
Release v1.0.0
2 parents 9f56411 + 514f803 commit dbe5eeb

File tree

10 files changed

+721
-4
lines changed

10 files changed

+721
-4
lines changed
 

‎GitVersion.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
mode: ContinuousDelivery
2+
next-version: 1.0.0
3+
branches: {}
4+
ignore:
5+
sha: []

‎README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Xer.Cqrs.CommandStack.Extensions.Attributes
2+
Attribute registration extension for Xer.Cqrs.CommandStack
3+
4+
# Build
5+
| Branch | Status |
6+
|--------|--------|
7+
| Master | [![Build status](https://ci.appveyor.com/api/projects/status/j6omv8ir8whiraya?svg=true)](https://ci.appveyor.com/project/XerProjects25246/xer-cqrs-commandstack-extensions-attributes) |
8+
| Dev | [![Build status](https://ci.appveyor.com/api/projects/status/j6omv8ir8whiraya/branch/dev?svg=true)](https://ci.appveyor.com/project/XerProjects25246/xer-cqrs-commandstack-extensions-attributes/branch/dev) |
9+
10+
# Nuget
11+
[![NuGet](https://img.shields.io/nuget/vpre/xer.cqrs.commandstack.extensions.attributes.svg)](https://www.nuget.org/packages/Xer.Cqrs.CommandStack.Extensions.Attributes/)

‎Src/Xer.Cqrs.CommandStack.Extensions.Attributes/SingleMessageHandlerRegistrationExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using Xer.Cqrs.CommandStack;
66
using Xer.Cqrs.CommandStack.Extensions.Attributes;
77

8-
namespace Xer.Delegator.Registrations
8+
namespace Xer.Delegator.Registration
99
{
1010
public static partial class SingleMessageHandlerRegistrationExtensions
1111
{
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFramework>netstandard1.0</TargetFramework>
5+
<Authors>jeyjeyemem;mvput;xerprojects-contributors;</Authors>
6+
<Description>Attribute-based registration extension for Xer.Cqrs.CommandStack.</Description>
7+
<Copyright>Copyright (c) XerProjects contributors</Copyright>
8+
<PackageLicenseUrl>https://github.com/XerProjects/Xer.Cqrs.CommandStack.Extensions.Attributes/blob/master/LICENSE</PackageLicenseUrl>
9+
<PackageProjectUrl>https://github.com/XerProjects/Xer.Cqrs.CommandStack.Extensions.Attributes</PackageProjectUrl>
10+
<PackageTags>cqrs;attribute;command;command-handler;command-handling;command-message;</PackageTags>
511
</PropertyGroup>
612

713
<ItemGroup>
8-
<PackageReference Include="Xer.Delegator" Version="0.3.0" />
14+
<PackageReference Include="Xer.Delegator" Version="1.0.0" />
915
</ItemGroup>
1016

1117
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0"?>
2+
<package>
3+
<metadata>
4+
<id>Xer.Cqrs.CommandStack.Extensions.Attributes</id>
5+
<version>1.0.0</version>
6+
<title>Xer.Cqrs.CommandStack.Extensions.Attributes</title>
7+
<authors>jeyjeyemem</authors>
8+
<owners>jeyjeyemem</owners>
9+
<licenseUrl>https://github.com/XerProjects/Xer.Cqrs.CommandStack.Extensions.Attributes/blob/master/LICENSE</licenseUrl>
10+
<projectUrl>https://github.com/XerProjects/Xer.Cqrs.CommandStack.Extensions.Attributes</projectUrl>
11+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
12+
<description>Attribute-based registration extension for Xer.Cqrs.CommandStack.</description>
13+
<summary>Attribute-based registration extension for Xer.Cqrs.CommandStack.</summary>
14+
<releaseNotes>
15+
- Initial release
16+
</releaseNotes>
17+
<copyright>Copyright 2017</copyright>
18+
<tags>CQRS Command Handler Attribute</tags>
19+
</metadata>
20+
<files>
21+
<file src="bin\Release\netstandard1.0\*.dll" target="lib\netstandard1.0" />
22+
</files>
23+
</package>

‎Tests/Xer.Cqrs.CommandStack.Extensions.Attributes.Tests/Registration/AttributeRegistrationTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using Xer.Cqrs.CommandStack;
88
using Xer.Cqrs.CommandStack.Extensions.Attributes.Tests.Entities;
99
using Xer.Delegator;
10-
using Xer.Delegator.Registrations;
10+
using Xer.Delegator.Registration;
1111
using Xunit;
1212
using Xunit.Abstractions;
1313

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

‎build.cake

+316
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,316 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
// ADDINS/TOOLS
3+
///////////////////////////////////////////////////////////////////////////////
4+
#tool "nuget:?package=GitVersion.CommandLine"
5+
#addin nuget:?package=Cake.Git
6+
7+
///////////////////////////////////////////////////////////////////////////////
8+
// ARGUMENTS
9+
///////////////////////////////////////////////////////////////////////////////
10+
11+
var target = Argument<string>("target", "Default");
12+
var configuration = Argument<string>("configuration", "Release");
13+
14+
///////////////////////////////////////////////////////////////////////////////
15+
// GLOBAL VARIABLES
16+
///////////////////////////////////////////////////////////////////////////////
17+
18+
var solutions = GetFiles("./**/*.sln");
19+
var projects = GetFiles("./**/*.csproj").Select(x => x.GetDirectory());
20+
21+
GitVersion gitVersion;
22+
23+
///////////////////////////////////////////////////////////////////////////////
24+
// SETUP / TEARDOWN
25+
///////////////////////////////////////////////////////////////////////////////
26+
27+
Setup(context =>
28+
{
29+
gitVersion = GitVersion(new GitVersionSettings {
30+
UpdateAssemblyInfo = true
31+
});
32+
33+
BuildParameters.Initialize(Context);
34+
35+
// Executed BEFORE the first task.
36+
Information("Xer.Cqrs.CommandStack.Extensions.Attributes");
37+
Information("Parameters");
38+
Information("///////////////////////////////////////////////////////////////////////////////");
39+
Information("Branch: {0}", BuildParameters.Instance.BranchName);
40+
Information("Version semver: {0}", gitVersion.LegacySemVerPadded);
41+
Information("Version assembly: {0}", gitVersion.MajorMinorPatch);
42+
Information("Version informational: {0}", gitVersion.InformationalVersion);
43+
Information("Master branch: {0}", BuildParameters.Instance.IsMasterBranch);
44+
Information("Dev branch: {0}", BuildParameters.Instance.IsDevBranch);
45+
Information("Hotfix branch: {0}", BuildParameters.Instance.IsHotFixBranch);
46+
Information("Publish to myget: {0}", BuildParameters.Instance.ShouldPublishMyGet);
47+
Information("Publish to nuget: {0}", BuildParameters.Instance.ShouldPublishNuGet);
48+
Information("///////////////////////////////////////////////////////////////////////////////");
49+
});
50+
51+
Teardown(context =>
52+
{
53+
// Executed AFTER the last task.
54+
Information("Finished running tasks.");
55+
});
56+
57+
///////////////////////////////////////////////////////////////////////////////
58+
// TASK DEFINITIONS
59+
///////////////////////////////////////////////////////////////////////////////
60+
61+
Task("Clean")
62+
.Description("Cleans all directories that are used during the build process.")
63+
.Does(() =>
64+
{
65+
if (projects.Count() == 0)
66+
{
67+
Information("No projects found.");
68+
return;
69+
}
70+
71+
// Clean solution directories.
72+
foreach (var project in projects)
73+
{
74+
Information("Cleaning {0}", project);
75+
DotNetCoreClean(project.FullPath);
76+
}
77+
});
78+
79+
Task("Restore")
80+
.Description("Restores all the NuGet packages that are used by the specified solution.")
81+
.Does(() =>
82+
{
83+
if (solutions.Count() == 0)
84+
{
85+
Information("No solutions found.");
86+
return;
87+
}
88+
89+
var settings = new DotNetCoreRestoreSettings
90+
{
91+
ArgumentCustomization = args => args
92+
.Append("/p:Version={0}", gitVersion.LegacySemVerPadded)
93+
.Append("/p:AssemblyVersion={0}", gitVersion.MajorMinorPatch)
94+
.Append("/p:FileVersion={0}", gitVersion.MajorMinorPatch)
95+
.Append("/p:AssemblyInformationalVersion={0}", gitVersion.InformationalVersion)
96+
};
97+
98+
// Restore all NuGet packages.
99+
foreach (var solution in solutions)
100+
{
101+
Information("Restoring {0}...", solution);
102+
103+
DotNetCoreRestore(solution.FullPath, settings);
104+
}
105+
});
106+
107+
Task("Build")
108+
.Description("Builds all the different parts of the project.")
109+
.IsDependentOn("Clean")
110+
.IsDependentOn("Restore")
111+
.Does(() =>
112+
{
113+
if (solutions.Count() == 0)
114+
{
115+
Information("No solutions found.");
116+
return;
117+
}
118+
119+
var settings = new DotNetCoreBuildSettings
120+
{
121+
Configuration = configuration,
122+
ArgumentCustomization = args => args
123+
.Append("/p:Version={0}", gitVersion.LegacySemVerPadded)
124+
.Append("/p:AssemblyVersion={0}", gitVersion.MajorMinorPatch)
125+
.Append("/p:FileVersion={0}", gitVersion.MajorMinorPatch)
126+
.Append("/p:AssemblyInformationalVersion={0}", gitVersion.InformationalVersion)
127+
};
128+
129+
// Build all solutions.
130+
foreach (var solution in solutions)
131+
{
132+
Information("Building {0}", solution);
133+
134+
DotNetCoreBuild(solution.FullPath, settings);
135+
}
136+
});
137+
138+
Task("Test")
139+
.Description("Execute all unit test projects.")
140+
.IsDependentOn("Build")
141+
.Does(() =>
142+
{
143+
var projects = GetFiles("./Tests/**/*.Tests.csproj");
144+
145+
if (projects.Count == 0)
146+
{
147+
Information("No test projects found.");
148+
return;
149+
}
150+
151+
var settings = new DotNetCoreTestSettings
152+
{
153+
Configuration = configuration,
154+
NoBuild = true,
155+
};
156+
157+
foreach (var project in projects)
158+
{
159+
DotNetCoreTest(project.FullPath, settings);
160+
}
161+
});
162+
163+
Task("Pack")
164+
.IsDependentOn("Test")
165+
.Does(() =>
166+
{
167+
var projects = GetFiles("./src/**/*.csproj");
168+
169+
if (projects.Count() == 0)
170+
{
171+
Information("No projects found.");
172+
return;
173+
}
174+
175+
var settings = new DotNetCorePackSettings
176+
{
177+
OutputDirectory = "./BuildArtifacts",
178+
NoBuild = true,
179+
Configuration = configuration,
180+
ArgumentCustomization = (args) => args
181+
.Append("/p:Version={0}", gitVersion.LegacySemVerPadded)
182+
.Append("/p:AssemblyVersion={0}", gitVersion.MajorMinorPatch)
183+
.Append("/p:FileVersion={0}", gitVersion.MajorMinorPatch)
184+
.Append("/p:AssemblyInformationalVersion={0}", gitVersion.InformationalVersion)
185+
};
186+
187+
foreach (var project in projects)
188+
{
189+
DotNetCorePack(project.ToString(), settings);
190+
}
191+
});
192+
193+
Task("PublishMyGet")
194+
.WithCriteria(() => BuildParameters.Instance.ShouldPublishMyGet)
195+
.IsDependentOn("Pack")
196+
.Does(() =>
197+
{
198+
var nupkgs = GetFiles("./**/*.nupkg");
199+
200+
if (nupkgs.Count() == 0)
201+
{
202+
Information("No nupkgs found.");
203+
return;
204+
}
205+
206+
foreach (var nupkgFile in nupkgs)
207+
{
208+
Information("Pulishing to myget {0}", nupkgFile);
209+
210+
NuGetPush(nupkgFile, new NuGetPushSettings
211+
{
212+
Source = BuildParameters.Instance.MyGetFeed,
213+
ApiKey = BuildParameters.Instance.MyGetApiKey
214+
});
215+
}
216+
});
217+
218+
Task("PublishNuGet")
219+
.WithCriteria(() => BuildParameters.Instance.ShouldPublishNuGet)
220+
.IsDependentOn("Pack")
221+
.Does(() =>
222+
{
223+
var nupkgs = GetFiles("./**/*.nupkg");
224+
225+
if (nupkgs.Count() == 0)
226+
{
227+
Information("No nupkgs found.");
228+
return;
229+
}
230+
231+
foreach (var nupkgFile in nupkgs)
232+
{
233+
Information("Pulishing to nuget {0}", nupkgFile);
234+
NuGetPush(nupkgFile, new NuGetPushSettings
235+
{
236+
Source = BuildParameters.Instance.NuGetFeed,
237+
ApiKey = BuildParameters.Instance.NuGetApiKey
238+
});
239+
}
240+
});
241+
242+
243+
///////////////////////////////////////////////////////////////////////////////
244+
// TARGETS
245+
///////////////////////////////////////////////////////////////////////////////
246+
247+
Task("Default")
248+
.Description("This is the default task which will be ran if no specific target is passed in.")
249+
.IsDependentOn("PublishNuGet")
250+
.IsDependentOn("PublishMyGet");
251+
252+
///////////////////////////////////////////////////////////////////////////////
253+
// EXECUTION
254+
///////////////////////////////////////////////////////////////////////////////
255+
256+
RunTarget(target);
257+
258+
public class BuildParameters
259+
{
260+
private static BuildParameters _buildParameters;
261+
262+
public static BuildParameters Instance => _buildParameters;
263+
264+
private ICakeContext _context;
265+
266+
private BuildParameters(ICakeContext context)
267+
{
268+
_context = context;
269+
}
270+
271+
public static void Initialize(ICakeContext context)
272+
{
273+
if(_buildParameters != null)
274+
{
275+
return;
276+
}
277+
278+
_buildParameters = new BuildParameters(context);
279+
}
280+
281+
public bool IsAppVeyorBuild => _context.BuildSystem().AppVeyor.IsRunningOnAppVeyor;
282+
283+
public bool IsLocalBuild => _context.BuildSystem().IsLocalBuild;
284+
285+
public string BranchName
286+
{
287+
get
288+
{
289+
return IsLocalBuild
290+
? _context.GitBranchCurrent(".").FriendlyName
291+
: _context.BuildSystem().AppVeyor.Environment.Repository.Branch;
292+
}
293+
}
294+
295+
public string MyGetFeed => _context.EnvironmentVariable("MYGET_SOURCE");
296+
297+
public string MyGetApiKey => _context.EnvironmentVariable("MYGET_API_KEY");
298+
299+
public string NuGetFeed => _context.EnvironmentVariable("NUGET_SOURCE");
300+
301+
public string NuGetApiKey => _context.EnvironmentVariable("NUGET_API_KEY");
302+
303+
public bool IsMasterBranch => StringComparer.OrdinalIgnoreCase.Equals("master", BranchName);
304+
305+
public bool IsDevBranch => StringComparer.OrdinalIgnoreCase.Equals("dev", BranchName);
306+
307+
public bool IsReleaseBranch => BranchName.StartsWith("release", StringComparison.OrdinalIgnoreCase);
308+
309+
public bool IsHotFixBranch => BranchName.StartsWith("hotfix", StringComparison.OrdinalIgnoreCase);
310+
311+
public bool ShouldPublishMyGet => !string.IsNullOrWhiteSpace(MyGetApiKey) && !string.IsNullOrWhiteSpace(MyGetFeed);
312+
313+
public bool ShouldPublishNuGet => !string.IsNullOrWhiteSpace(NuGetApiKey)
314+
&& !string.IsNullOrWhiteSpace(NuGetFeed)
315+
&& (IsMasterBranch || IsHotFixBranch);
316+
}

‎build.ps1

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

‎build.sh

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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+
ADDINS_DIR=$TOOLS_DIR/Addins
13+
MODULES_DIR=$TOOLS_DIR/Modules
14+
NUGET_EXE=$TOOLS_DIR/nuget.exe
15+
CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe
16+
PACKAGES_CONFIG=$TOOLS_DIR/packages.config
17+
PACKAGES_CONFIG_MD5=$TOOLS_DIR/packages.config.md5sum
18+
ADDINS_PACKAGES_CONFIG=$ADDINS_DIR/packages.config
19+
MODULES_PACKAGES_CONFIG=$MODULES_DIR/packages.config
20+
21+
# Define md5sum or md5 depending on Linux/OSX
22+
MD5_EXE=
23+
if [[ "$(uname -s)" == "Darwin" ]]; then
24+
MD5_EXE="md5 -r"
25+
else
26+
MD5_EXE="md5sum"
27+
fi
28+
29+
# Define default arguments.
30+
SCRIPT="build.cake"
31+
CAKE_ARGUMENTS=()
32+
33+
# Parse arguments.
34+
for i in "$@"; do
35+
case $1 in
36+
-s|--script) SCRIPT="$2"; shift ;;
37+
--) shift; CAKE_ARGUMENTS+=("$@"); break ;;
38+
*) CAKE_ARGUMENTS+=("$1") ;;
39+
esac
40+
shift
41+
done
42+
43+
# Make sure the tools folder exist.
44+
if [ ! -d "$TOOLS_DIR" ]; then
45+
mkdir "$TOOLS_DIR"
46+
fi
47+
48+
# Make sure that packages.config exist.
49+
if [ ! -f "$TOOLS_DIR/packages.config" ]; then
50+
echo "Downloading packages.config..."
51+
curl -Lsfo "$TOOLS_DIR/packages.config" https://cakebuild.net/download/bootstrapper/packages
52+
if [ $? -ne 0 ]; then
53+
echo "An error occurred while downloading packages.config."
54+
exit 1
55+
fi
56+
fi
57+
58+
# Download NuGet if it does not exist.
59+
if [ ! -f "$NUGET_EXE" ]; then
60+
echo "Downloading NuGet..."
61+
curl -Lsfo "$NUGET_EXE" https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
62+
if [ $? -ne 0 ]; then
63+
echo "An error occurred while downloading nuget.exe."
64+
exit 1
65+
fi
66+
fi
67+
68+
# Restore tools from NuGet.
69+
pushd "$TOOLS_DIR" >/dev/null
70+
if [ ! -f "$PACKAGES_CONFIG_MD5" ] || [ "$( cat "$PACKAGES_CONFIG_MD5" | sed 's/\r$//' )" != "$( $MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' )" ]; then
71+
find . -type d ! -name . ! -name 'Cake.Bakery' | xargs rm -rf
72+
fi
73+
74+
mono "$NUGET_EXE" install -ExcludeVersion
75+
if [ $? -ne 0 ]; then
76+
echo "Could not restore NuGet tools."
77+
exit 1
78+
fi
79+
80+
$MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' >| "$PACKAGES_CONFIG_MD5"
81+
82+
popd >/dev/null
83+
84+
# Restore addins from NuGet.
85+
if [ -f "$ADDINS_PACKAGES_CONFIG" ]; then
86+
pushd "$ADDINS_DIR" >/dev/null
87+
88+
mono "$NUGET_EXE" install -ExcludeVersion
89+
if [ $? -ne 0 ]; then
90+
echo "Could not restore NuGet addins."
91+
exit 1
92+
fi
93+
94+
popd >/dev/null
95+
fi
96+
97+
# Restore modules from NuGet.
98+
if [ -f "$MODULES_PACKAGES_CONFIG" ]; then
99+
pushd "$MODULES_DIR" >/dev/null
100+
101+
mono "$NUGET_EXE" install -ExcludeVersion
102+
if [ $? -ne 0 ]; then
103+
echo "Could not restore NuGet modules."
104+
exit 1
105+
fi
106+
107+
popd >/dev/null
108+
fi
109+
110+
# Make sure that Cake has been installed.
111+
if [ ! -f "$CAKE_EXE" ]; then
112+
echo "Could not find Cake.exe at '$CAKE_EXE'."
113+
exit 1
114+
fi
115+
116+
# Start Cake
117+
exec mono "$CAKE_EXE" $SCRIPT "${CAKE_ARGUMENTS[@]}"

0 commit comments

Comments
 (0)
Please sign in to comment.