Skip to content

Commit b9d5796

Browse files
Add Cake build scripts
1 parent 82c5535 commit b9d5796

File tree

13 files changed

+203
-9
lines changed

13 files changed

+203
-9
lines changed

.config/dotnet-tools.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
"isRoot": true,
44
"tools": {
55
"cake.tool": {
6-
"version": "0.38.5",
6+
"version": "1.0.0",
77
"commands": [
88
"dotnet-cake"
99
]
1010
},
1111
"minver-cli": {
12-
"version": "2.3.1",
12+
"version": "2.4.0",
1313
"commands": [
1414
"minver"
1515
]

.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

.github/workflows/dependabot-cake.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
on:
2+
schedule:
3+
# every Sunday at 6am
4+
- cron: '0 6 * * SUN'
5+
6+
workflow_dispatch:
7+
8+
jobs:
9+
dependabot-cake:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: check/update cake dependencies
13+
uses: augustoproiete-actions/nils-org--dependabot-cake-action@v1

.gitignore

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ Thumbs.db
2828
*.nupkg
2929
**/packages/*
3030

31-
#Ignore files created by ReSharper
32-
_ReSharper*/
33-
34-
#Ignore files created by NUnit
35-
TestResult.xml
36-
*.VisualState.xml
31+
#cake
32+
.cake/
33+
/artifacts/*

Directory.Build.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<Project>
2+
23
<PropertyGroup>
34
<LangVersion>latest</LangVersion>
45
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<SourceRoot Include="$(MSBuildThisFileDirectory)/"/>
9+
</ItemGroup>
10+
511
</Project>

build.cake

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

build.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
$ErrorActionPreference = 'Stop'
2+
3+
Set-Location -LiteralPath $PSScriptRoot
4+
5+
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1'
6+
$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1'
7+
$env:DOTNET_NOLOGO = '1'
8+
9+
dotnet tool restore
10+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
11+
12+
dotnet cake @args
13+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

build.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
set -euox pipefail
3+
4+
cd "$(dirname "${BASH_SOURCE[0]}")"
5+
6+
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
7+
export DOTNET_CLI_TELEMETRY_OPTOUT=1
8+
export DOTNET_NOLOGO=1
9+
10+
dotnet tool restore
11+
12+
dotnet cake "$@"

cake.config

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[Nuget]
2+
Source=https://api.nuget.org/v3/index.json
3+
UseInProcessClient=true
4+
LoadDependencies=false
5+
6+
[Paths]
7+
Tools=./.cake
8+
Addins=./.cake/addins
9+
Modules=./.cake/modules
10+
11+
[Settings]
12+
SkipVerification=false

0 commit comments

Comments
 (0)