Skip to content

Commit 1d02411

Browse files
committed
[-] Remove cake
1 parent e8517bd commit 1d02411

File tree

2 files changed

+51
-63
lines changed

2 files changed

+51
-63
lines changed

build.cake

Lines changed: 0 additions & 57 deletions
This file was deleted.

build.ps1

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,60 @@
1-
$ErrorActionPreference = 'Stop'
2-
1+
$ErrorActionPreference = "Stop"
32
Set-Location -LiteralPath $PSScriptRoot
43

54
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1'
65
$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1'
76
$env:DOTNET_NOLOGO = '1'
87

9-
dotnet tool restore
10-
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
8+
# ==========================================
9+
# 1. Restore
10+
# ==========================================
11+
Write-Host "Restoring packages..." -ForegroundColor Cyan
12+
dotnet restore "./AquaMai.slnx"
13+
14+
# ==========================================
15+
# 2. PreBuild: Generate BuildInfo.g.cs
16+
# ==========================================
17+
Write-Host "Generating BuildInfo..." -ForegroundColor Cyan
18+
try {
19+
$gitDescribe = git describe --tags --long
20+
# remove 'v' if exists
21+
if ($gitDescribe.StartsWith("v")) {
22+
$gitDescribe = $gitDescribe.Substring(1)
23+
}
24+
25+
$buildDate = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
26+
27+
$shortVers = $gitDescribe.Split('-')
28+
$shortVer = $shortVers[0]
29+
if ($shortVers.Length -gt 1) {
30+
$shortVer = "$($shortVers[0]).$($shortVers[1])"
31+
}
32+
33+
$versionContent = @"
34+
// Auto-generated file. Do not modify manually.
35+
namespace AquaMai;
36+
37+
public static partial class BuildInfo
38+
{
39+
public const string Version = "$shortVer";
40+
public const string GitVersion = "$gitDescribe";
41+
public const string BuildDate = "$buildDate";
42+
}
43+
"@
44+
Set-Content "./AquaMai/BuildInfo.g.cs" $versionContent -Encoding UTF8
45+
} catch {
46+
Write-Warning "Failed to generate BuildInfo.g.cs (Git describe failed?): $_"
47+
# Fallback if needed, or just continue
48+
}
1149

12-
taskkill.exe /f /im dotnet.exe
50+
# ==========================================
51+
# 3. Build
52+
# ==========================================
53+
Write-Host "Building Solution..." -ForegroundColor Cyan
54+
$Configuration = "Release"
55+
if ($args.Count -gt 0 -and $args[0] -eq "-Configuration") {
56+
$Configuration = $args[1]
57+
}
1358

14-
dotnet cake @args
59+
dotnet build "./AquaMai.slnx" -c $Configuration
1560
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

0 commit comments

Comments
 (0)