Skip to content

Commit a20e3cd

Browse files
Add Cake build script and bootstrappers
1 parent dc2e2d7 commit a20e3cd

File tree

5 files changed

+150
-16
lines changed

5 files changed

+150
-16
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
* text=auto
33

44
# Explicitly declare files that should always be converted to LF regardless of platform
5+
*.sh text eol=lf
56
*.dotsettings text eol=lf

.gitignore

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,28 @@
1-
#Ignore thumbnails created by Windows
1+
#windows
22
Thumbs.db
33

4-
#Ignore metadata created by OSX
4+
#osx
55
.DS_Store
66
._*
77

8-
#Ignore files created by Visual Studio
8+
#visual-studio
99
.vs/
1010
*.user
1111
*.suo
1212
*.tmp_proj
13-
*.dbmdl
14-
*.dbproj.schemaview
1513
*.cache
1614
*.vsdoc
1715
[Oo]bj/
1816
[Bb]in/
1917
[Dd]ebug/
2018
[Rr]elease/
21-
[Rr][Cc]/
22-
[Cc]ode[Cc]overage/
23-
[Ff]x[Cc]op/
2419
[Ll]og/
2520
[Tt]emp/
2621

27-
# Ignore NuGet Packages
22+
#nuget
2823
*.nupkg
2924
**/packages/*
3025

31-
#Ignore files created by ReSharper
32-
_ReSharper*/
33-
34-
#Ignore files created by NUnit
35-
TestResult.xml
36-
*.VisualState.xml
37-
/Ookii.Dialogs.Wpf.NETCore/Properties/PublishProfiles
26+
#cake
27+
/build/*
28+
/tools/*

build.cake

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#addin "nuget:?package=Cake.MinVer&version=0.1.0"
2+
3+
var target = Argument<string>("target", "publish");
4+
var buildVersion = MinVer(s => s.WithTagPrefix("v").WithDefaultPreReleasePhase("preview"));
5+
6+
Task("clean")
7+
.Does(() =>
8+
{
9+
CleanDirectory("./build/artifacts");
10+
CleanDirectories("./src/**/bin");
11+
CleanDirectories("./src/**/obj");
12+
CleanDirectories("./test/**/bin");
13+
CleanDirectories("./test/**/obj");
14+
});
15+
16+
Task("restore")
17+
.IsDependentOn("clean")
18+
.Does(() =>
19+
{
20+
DotNetCoreRestore("./Ookii.Dialogs.Wpf.sln", new DotNetCoreRestoreSettings
21+
{
22+
LockedMode = true,
23+
});
24+
});
25+
26+
Task("build")
27+
.IsDependentOn("restore")
28+
.Does(() =>
29+
{
30+
DotNetCoreBuild("./Ookii.Dialogs.Wpf.sln", new DotNetCoreBuildSettings
31+
{
32+
Configuration = "Debug",
33+
NoRestore = true,
34+
NoIncremental = false,
35+
ArgumentCustomization = args =>
36+
args.AppendQuoted($"-p:Version={buildVersion.Version}")
37+
.AppendQuoted($"-p:FileVersion={buildVersion.FileVersion}")
38+
.AppendQuoted($"-p:ContinuousIntegrationBuild=true")
39+
});
40+
41+
DotNetCoreBuild("./Ookii.Dialogs.Wpf.sln", new DotNetCoreBuildSettings
42+
{
43+
Configuration = "Release",
44+
NoRestore = true,
45+
NoIncremental = false,
46+
ArgumentCustomization = args =>
47+
args.AppendQuoted($"-p:Version={buildVersion.Version}")
48+
.AppendQuoted($"-p:FileVersion={buildVersion.FileVersion}")
49+
.AppendQuoted($"-p:ContinuousIntegrationBuild=true")
50+
});
51+
});
52+
53+
Task("test")
54+
.IsDependentOn("build")
55+
.Does(() =>
56+
{
57+
var settings = new DotNetCoreTestSettings
58+
{
59+
Configuration = "Release",
60+
NoRestore = true,
61+
NoBuild = true,
62+
};
63+
64+
var projectFiles = GetFiles("./test/**/*.csproj");
65+
foreach (var file in projectFiles)
66+
{
67+
DotNetCoreTest(file.FullPath, settings);
68+
}
69+
});
70+
71+
Task("pack")
72+
.IsDependentOn("test")
73+
.Does(() =>
74+
{
75+
var releaseNotes = $"https://github.com/augustoproiete/ookii-dialogs-wpf/releases/tag/v{buildVersion.Version}";
76+
77+
DotNetCorePack("./src/Ookii.Dialogs.Wpf/Ookii.Dialogs.Wpf.csproj", new DotNetCorePackSettings
78+
{
79+
Configuration = "Release",
80+
NoRestore = true,
81+
NoBuild = true,
82+
IncludeSymbols = true,
83+
IncludeSource = true,
84+
OutputDirectory = "./build/artifacts",
85+
ArgumentCustomization = args =>
86+
args.AppendQuoted($"-p:Version={buildVersion.Version}")
87+
.AppendQuoted($"-p:PackageReleaseNotes={releaseNotes}")
88+
});
89+
});
90+
91+
Task("publish")
92+
.IsDependentOn("pack")
93+
.Does(context =>
94+
{
95+
var url = context.EnvironmentVariable("NUGET_URL");
96+
if (string.IsNullOrWhiteSpace(url))
97+
{
98+
context.Information("No NuGet URL specified. Skipping publishing of NuGet packages");
99+
return;
100+
}
101+
102+
var apiKey = context.EnvironmentVariable("NUGET_API_KEY");
103+
if (string.IsNullOrWhiteSpace(apiKey))
104+
{
105+
context.Information("No NuGet API key specified. Skipping publishing of NuGet packages");
106+
return;
107+
}
108+
109+
var nugetPushSettings = new DotNetCoreNuGetPushSettings
110+
{
111+
Source = url,
112+
ApiKey = apiKey,
113+
};
114+
115+
foreach (var nugetPackageFile in GetFiles("./build/artifacts/*.nupkg"))
116+
{
117+
DotNetCoreNuGetPush(nugetPackageFile.FullPath, nugetPushSettings);
118+
}
119+
});
120+
121+
RunTarget(target);

build.cmd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@echo on
2+
@cd %~dp0
3+
4+
set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
5+
set DOTNET_CLI_TELEMETRY_OPTOUT=1
6+
set DOTNET_NOLOGO=1
7+
8+
dotnet tool restore
9+
@if %ERRORLEVEL% neq 0 goto :eof
10+
11+
dotnet cake --verbosity=diagnostic %*

build.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
set -euox pipefail
3+
4+
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
5+
export DOTNET_CLI_TELEMETRY_OPTOUT=1
6+
export DOTNET_NOLOGO=1
7+
8+
dotnet tool restore
9+
10+
dotnet cake --verbosity=diagnostic $@

0 commit comments

Comments
 (0)