Skip to content

Commit 5c1efef

Browse files
committed
initial cake support
1 parent 976689d commit 5c1efef

File tree

5 files changed

+183
-16
lines changed

5 files changed

+183
-16
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -327,4 +327,7 @@ ASALocalRun/
327327
*.nvuser
328328

329329
# MFractors (Xamarin productivity tool) working folder
330-
.mfractor/
330+
.mfractor/
331+
332+
# cakebuild tools
333+
tools/

.vscode/tasks.json

+6-15
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,12 @@
44
"version": "2.0.0",
55
"tasks": [
66
{
7-
"label": "build",
8-
"type": "shell",
9-
"command": "msbuild",
10-
"args": [
11-
// Ask msbuild to generate full paths for file names.
12-
"/property:GenerateFullPaths=true",
13-
"/t:build"
14-
],
15-
"group": "build",
16-
"presentation": {
17-
// Reveal the output only if unrecognized errors occur.
18-
"reveal": "silent"
19-
},
20-
// Use the standard MS compiler pattern to detect errors, warnings and infos
21-
"problemMatcher": "$msCompile"
7+
"type": "cake",
8+
"script": "Default",
9+
"group": {
10+
"kind": "build",
11+
"isDefault": true
12+
}
2213
}
2314
]
2415
}

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ The LightStep distributed tracing library for C#
1111
This translates to requiring at least Visual Studio 2017 (15.0).
1212
You may need [PostSharp](https://www.postsharp.net/) to work on the `LightStep.CSharpAspectTestApp`.
1313

14+
## MacOS
15+
Due to an issue with Cake's detection of the `msbuild` path, the Mono Framework needs to be installed via its installer and **not** Homebrew.
16+
1417
# Installation
1518
Install the package via NuGet into your solution, or use `Install-Package LightStep`.
1619

build.cake

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#tool "xunit.runner.console"
2+
3+
var target = Argument("target", "Default");
4+
var configuration = Argument("configuration", "Release");
5+
var buildDir = Directory("./build");
6+
var distDir = Directory("./dist");
7+
var solutionFile = GetFiles("./*.sln").First();
8+
var solution = new Lazy<SolutionParserResult>(() => ParseSolution(solutionFile));
9+
10+
11+
Task("Clean")
12+
.IsDependentOn("Clean-Outputs")
13+
.Does(() =>
14+
{
15+
MSBuild(solutionFile, settings => settings
16+
.SetConfiguration(configuration)
17+
.WithTarget("Clean")
18+
.SetVerbosity(Verbosity.Minimal));
19+
});
20+
21+
Task("Clean-Outputs")
22+
.Does(() =>
23+
{
24+
CleanDirectory(buildDir);
25+
CleanDirectory(distDir);
26+
});
27+
28+
Task("Build")
29+
.IsDependentOn("Clean-Outputs")
30+
.Does(() =>
31+
{
32+
NuGetRestore(solutionFile);
33+
34+
MSBuild(solutionFile, settings => settings
35+
.SetConfiguration(configuration)
36+
.WithTarget("Rebuild")
37+
.SetVerbosity(Verbosity.Minimal));
38+
});
39+
40+
Task("Test")
41+
.IsDependentOn("Build")
42+
.Does(() =>
43+
{
44+
XUnit2(string.Format("./test/**/bin/{0}/*.Tests.dll", configuration), new XUnit2Settings {
45+
XmlReport = true,
46+
OutputDirectory = buildDir
47+
});
48+
});
49+
50+
Task("Default")
51+
.IsDependentOn("Build");
52+
53+
RunTarget(target);

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)