Skip to content

Commit fb0e6a8

Browse files
authored
Merge pull request #9 from synercoder/azure-pipelines
Set up CI with Azure Pipelines
2 parents 9933f77 + 0e92276 commit fb0e6a8

File tree

6 files changed

+516
-0
lines changed

6 files changed

+516
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ bld/
2424
[Oo]bj/
2525
[Ll]og/
2626

27+
# Automated build script temp directory
28+
/tools/
29+
2730
# Visual Studio 2015/2017 cache/options directory
2831
.vs/
2932
# Uncomment if you have tasks that create the project's static files in wwwroot

Synercoding.FileFormats.Pdf.sln

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1717
ProjectSection(SolutionItems) = preProject
1818
.editorconfig = .editorconfig
1919
.gitignore = .gitignore
20+
azure-pipelines.yml = azure-pipelines.yml
21+
build.cake = build.cake
22+
build.ps1 = build.ps1
23+
build.sh = build.sh
2024
LICENSE = LICENSE
2125
README.md = README.md
2226
EndProjectSection

azure-pipelines.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
trigger:
2+
- master
3+
4+
jobs:
5+
6+
- job: Linux
7+
pool:
8+
vmImage: 'ubuntu-16.04'
9+
steps:
10+
- bash: ./build.sh
11+
env:
12+
COREHOST_TRACE: 0
13+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
14+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
15+
16+
- job: macOS
17+
pool:
18+
vmImage: 'macOS-10.13'
19+
steps:
20+
- bash: ./build.sh
21+
env:
22+
COREHOST_TRACE: 0
23+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
24+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
25+
26+
- job: Windows
27+
pool:
28+
vmImage: 'vs2017-win2016'
29+
steps:
30+
- powershell: .\build.ps1
31+
env:
32+
COREHOST_TRACE: 0
33+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
34+
DOTNET_CLI_TELEMETRY_OPTOUT: 1

build.cake

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
// Taken from https://github.com/andrewlock/NetEscapades.Configuration/ under MIT license
2+
3+
// Kudos to Muhammed Rehan Saeed for this script!
4+
// http://rehansaeed.com/cross-platform-devops-net-core/
5+
6+
// Target - The task you want to start. Runs the Default task if not specified.
7+
var target = Argument("Target", "Default");
8+
var configuration = Argument("Configuration", "Release");
9+
10+
Information("Running target " + target + " in configuration " + configuration);
11+
12+
// The build number to use in the version number of the built NuGet packages.
13+
// There are multiple ways this value can be passed, this is a common pattern.
14+
// 1. If command line parameter parameter passed, use that.
15+
// 2. Otherwise if running on AppVeyor, get it's build number.
16+
// 3. Otherwise if running on Travis CI, get it's build number.
17+
// 4. Otherwise if an Environment variable exists, use that.
18+
// 5. Otherwise default the build number to 1.
19+
var buildNumber =
20+
HasArgument("BuildNumber") ? Argument<int>("BuildNumber") :
21+
AppVeyor.IsRunningOnAppVeyor ? AppVeyor.Environment.Build.Number :
22+
TravisCI.IsRunningOnTravisCI ? TravisCI.Environment.Build.BuildNumber :
23+
EnvironmentVariable("BuildNumber") != null ? int.Parse(EnvironmentVariable("BuildNumber")) : 1;
24+
25+
// Assume we're building on appveyor for publishing NuGets
26+
// So always add a beta prefix if not doing a tag
27+
var isTag = EnvironmentVariable("APPVEYOR_REPO_TAG") != null && EnvironmentVariable("APPVEYOR_REPO_TAG") == "true" ;
28+
var revision = isTag ? null : "beta-" +buildNumber.ToString("D4");
29+
// A directory path to an Artifacts directory.
30+
var artifactsDirectory = Directory("./artifacts");
31+
32+
// Deletes the contents of the Artifacts folder if it should contain anything from a previous build.
33+
Task("Clean")
34+
.Does(() =>
35+
{
36+
CleanDirectory(artifactsDirectory);
37+
});
38+
39+
// Run dotnet restore to restore all package references.
40+
Task("Restore")
41+
.IsDependentOn("Clean")
42+
.Does(() =>
43+
{
44+
DotNetCoreRestore();
45+
});
46+
47+
// Find all sln files and build them using the build configuration specified as an argument.
48+
Task("Build")
49+
.IsDependentOn("Restore")
50+
.Does(() =>
51+
{
52+
var solutions = GetFiles("./*.sln");
53+
foreach(var solution in solutions)
54+
{
55+
Information("Building solution " + solution);
56+
DotNetCoreBuild(
57+
solution.ToString(),
58+
new DotNetCoreBuildSettings()
59+
{
60+
Configuration = configuration
61+
});
62+
}
63+
});
64+
65+
// Look under a 'Tests' folder and run dotnet test against all of those projects.
66+
// Then drop the XML test results file in the Artifacts folder at the root.
67+
Task("Test")
68+
.IsDependentOn("Build")
69+
.Does(() =>
70+
{
71+
var projects = GetFiles("./test/**/*Tests.csproj");
72+
foreach(var project in projects)
73+
{
74+
Information("Testing project " + project);
75+
DotNetCoreTest(
76+
project.ToString(),
77+
new DotNetCoreTestSettings()
78+
{
79+
// Currently not possible? https://github.com/dotnet/cli/issues/3114
80+
// ArgumentCustomization = args => args
81+
// .Append("-xml")
82+
// .Append(artifactsDirectory.Path.CombineWithFilePath(project.GetFilenameWithoutExtension()).FullPath + ".xml"),
83+
Configuration = configuration,
84+
NoBuild = true
85+
});
86+
}
87+
});
88+
89+
// Run dotnet pack to produce NuGet packages from our projects. Versions the package
90+
// using the build number argument on the script which is used as the revision number
91+
// (Last number in 1.0.0.0). The packages are dropped in the Artifacts directory.
92+
Task("Pack")
93+
.IsDependentOn("Test")
94+
.Does(() =>
95+
{
96+
foreach (var project in GetFiles("./src/**/*.csproj"))
97+
{
98+
Information("Packing project " + project);
99+
DotNetCorePack(
100+
project.ToString(),
101+
new DotNetCorePackSettings()
102+
{
103+
Configuration = configuration,
104+
OutputDirectory = artifactsDirectory,
105+
VersionSuffix = revision
106+
});
107+
}
108+
});
109+
110+
// The default task to run if none is explicitly specified. In this case, we want
111+
// to run everything starting from Clean, all the way up to Pack.
112+
Task("Default")
113+
.IsDependentOn("Pack");
114+
115+
// Executes the task specified in the target argument.
116+
RunTarget(target);

0 commit comments

Comments
 (0)