mirror of
https://github.com/hykilpikonna/AquaDX.git
synced 2026-08-27 19:54:52 -05:00
[-] Remove cake
This commit is contained in:
57
build.cake
57
build.cake
@@ -1,57 +0,0 @@
|
||||
#addin nuget:?package=Cake.Git&version=5.0.1
|
||||
#addin nuget:?package=Cake.FileHelpers&version=7.0.0
|
||||
|
||||
var target = Argument("target", "Build");
|
||||
var configuration = Argument("configuration", "Release");
|
||||
|
||||
Task("Restore")
|
||||
.Does(() =>
|
||||
{
|
||||
// 运行 dotnet restore
|
||||
DotNetRestore("./AquaMai.slnx");
|
||||
});
|
||||
|
||||
Task("PreBuild")
|
||||
.Does(() =>
|
||||
{
|
||||
var gitDescribe = GitDescribe(".", GitDescribeStrategy.Tags).Substring(1); // 获取 git describe 的输出
|
||||
var buildDate = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
|
||||
|
||||
var shortVers = gitDescribe.Split('-');
|
||||
string shortVer;
|
||||
if (shortVers.Length > 1)
|
||||
{
|
||||
shortVer = $"{shortVers[0]}.{shortVers[1]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
shortVer = shortVers[0];
|
||||
}
|
||||
|
||||
var versionContent = $@"
|
||||
// Auto-generated file. Do not modify manually.
|
||||
namespace AquaMai;
|
||||
|
||||
public static partial class BuildInfo
|
||||
{{
|
||||
public const string Version = ""{shortVer}"";
|
||||
public const string GitVersion = ""{gitDescribe}"";
|
||||
public const string BuildDate = ""{buildDate}"";
|
||||
}}
|
||||
";
|
||||
FileWriteText("./AquaMai/BuildInfo.g.cs", versionContent);
|
||||
});
|
||||
|
||||
Task("Build")
|
||||
.IsDependentOn("PreBuild")
|
||||
.IsDependentOn("Restore")
|
||||
.Does(() =>
|
||||
{
|
||||
// 使用 dotnet build 进行构建
|
||||
DotNetBuild("./AquaMai.slnx", new DotNetBuildSettings
|
||||
{
|
||||
Configuration = configuration
|
||||
});
|
||||
});
|
||||
|
||||
RunTarget(target);
|
||||
57
build.ps1
57
build.ps1
@@ -1,15 +1,60 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
Set-Location -LiteralPath $PSScriptRoot
|
||||
|
||||
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1'
|
||||
$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1'
|
||||
$env:DOTNET_NOLOGO = '1'
|
||||
|
||||
dotnet tool restore
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
# ==========================================
|
||||
# 1. Restore
|
||||
# ==========================================
|
||||
Write-Host "Restoring packages..." -ForegroundColor Cyan
|
||||
dotnet restore "./AquaMai.slnx"
|
||||
|
||||
taskkill.exe /f /im dotnet.exe
|
||||
# ==========================================
|
||||
# 2. PreBuild: Generate BuildInfo.g.cs
|
||||
# ==========================================
|
||||
Write-Host "Generating BuildInfo..." -ForegroundColor Cyan
|
||||
try {
|
||||
$gitDescribe = git describe --tags --long
|
||||
# remove 'v' if exists
|
||||
if ($gitDescribe.StartsWith("v")) {
|
||||
$gitDescribe = $gitDescribe.Substring(1)
|
||||
}
|
||||
|
||||
dotnet cake @args
|
||||
$buildDate = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
|
||||
|
||||
$shortVers = $gitDescribe.Split('-')
|
||||
$shortVer = $shortVers[0]
|
||||
if ($shortVers.Length -gt 1) {
|
||||
$shortVer = "$($shortVers[0]).$($shortVers[1])"
|
||||
}
|
||||
|
||||
$versionContent = @"
|
||||
// Auto-generated file. Do not modify manually.
|
||||
namespace AquaMai;
|
||||
|
||||
public static partial class BuildInfo
|
||||
{
|
||||
public const string Version = "$shortVer";
|
||||
public const string GitVersion = "$gitDescribe";
|
||||
public const string BuildDate = "$buildDate";
|
||||
}
|
||||
"@
|
||||
Set-Content "./AquaMai/BuildInfo.g.cs" $versionContent -Encoding UTF8
|
||||
} catch {
|
||||
Write-Warning "Failed to generate BuildInfo.g.cs (Git describe failed?): $_"
|
||||
# Fallback if needed, or just continue
|
||||
}
|
||||
|
||||
# ==========================================
|
||||
# 3. Build
|
||||
# ==========================================
|
||||
Write-Host "Building Solution..." -ForegroundColor Cyan
|
||||
$Configuration = "Release"
|
||||
if ($args.Count -gt 0 -and $args[0] -eq "-Configuration") {
|
||||
$Configuration = $args[1]
|
||||
}
|
||||
|
||||
dotnet build "./AquaMai.slnx" -c $Configuration
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
|
||||
Reference in New Issue
Block a user