Skip to content

Commit 5218181

Browse files
committed
Canary build script
1 parent 4d1107d commit 5218181

File tree

8 files changed

+252
-37
lines changed

8 files changed

+252
-37
lines changed

MaiChartManager.CLI/MaiChartManager.CLI.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
<PublishAot>False</PublishAot>
1515
<PublishReadyToRun>true</PublishReadyToRun>
1616
<PublishDir>..\Packaging\Pack</PublishDir>
17+
<Configurations>Debug;Release;Crack</Configurations>
18+
<Platforms>AnyCPU</Platforms>
19+
</PropertyGroup>
20+
21+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Crack|x64' ">
22+
<DefineConstants>CRACK</DefineConstants>
23+
<Optimize>true</Optimize>
1724
</PropertyGroup>
1825

1926
<ItemGroup>

MaiChartManager.CLI/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@
2424
AppMain.InitConfiguration(true);
2525
await IapManager.Init();
2626

27+
#if !CRACK
2728
if (IapManager.License != IapManager.LicenseStatus.Active)
2829
{
2930
Console.WriteLine("命令行工具目前为赞助版功能,请先使用桌面版应用程序解锁");
3031
return 1;
3132
}
33+
#endif
3234

3335
var app = new CommandApp();
3436

MaiChartManager/AppMain.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Diagnostics;
1+
using System.Diagnostics;
22
using System.Globalization;
33
using SingleInstanceCore;
44
using System.Text.Json;
@@ -12,7 +12,7 @@ namespace MaiChartManager;
1212

1313
public class AppMain : ISingleInstance
1414
{
15-
public const string Version = "1.7.2";
15+
public const string Version = "1.7.2.1";
1616
public static Browser? BrowserWin { get; set; }
1717

1818
private Launcher _launcher;
@@ -202,4 +202,13 @@ public static void SetLocale(string locale)
202202
var json = JsonSerializer.Serialize(StaticSettings.Config, new JsonSerializerOptions { WriteIndented = true });
203203
System.IO.File.WriteAllText(cfgFilePath, json);
204204
}
205-
}
205+
}
206+
207+
208+
209+
210+
211+
212+
213+
214+

MaiChartManager/MaiChartManager.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@
3434
<IsPublishable>True</IsPublishable>
3535
<PlatformTarget>x64</PlatformTarget>
3636
<DefineConstants/>
37+
<Optimize>true</Optimize>
3738
</PropertyGroup>
3839
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Crack|x64' ">
39-
<IsPublishable>False</IsPublishable>
40+
<IsPublishable>True</IsPublishable>
4041
<PlatformTarget>x64</PlatformTarget>
4142
<DefineConstants>CRACK</DefineConstants>
4243
<Optimize>true</Optimize>

Packaging/Build.ps1

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
param(
2+
[ValidateSet("Release", "Canary")]
3+
[string]$Mode = "Release",
4+
5+
# Canary 模式下的证书配置
6+
[string]$CanaryPublisher = "CN=凌莞"
7+
)
8+
9+
$ErrorActionPreference = "Stop"
10+
$ProjectRoot = Resolve-Path "$PSScriptRoot\.."
11+
12+
# ==========================================
13+
# 1. 版本号处理
14+
# ==========================================
15+
Write-Host "Calculating version..." -ForegroundColor Cyan
16+
$BuildVersion = "1.0.0.0"
17+
18+
try {
19+
Push-Location $ProjectRoot
20+
$gitDescribe = git describe --tags --long
21+
Pop-Location
22+
23+
if ($gitDescribe -match "v?(\d+\.\d+\.\d+)-(\d+)-g[0-9a-f]+") {
24+
$baseVer = $Matches[1]
25+
$commitCount = $Matches[2]
26+
27+
if ($Mode -eq "Canary") {
28+
$BuildVersion = "$baseVer.$commitCount"
29+
} else {
30+
# Release 模式保留三位 (补0)
31+
$BuildVersion = "$baseVer.0"
32+
}
33+
} else {
34+
Write-Warning "Git describe format mismatch: $gitDescribe. Fallback to $BuildVersion"
35+
}
36+
} catch {
37+
Write-Warning "Git describe failed. Fallback to $BuildVersion"
38+
}
39+
40+
Write-Host "Target Version: $BuildVersion" -ForegroundColor Green
41+
42+
# 修改 C# 源码版本号
43+
# Canary 模式使用完整的 4 段版本号 ($BuildVersion)
44+
# Release 模式使用 3 段版本号 ($baseVer)
45+
Write-Host "Updating C# source version..." -ForegroundColor Cyan
46+
$AppMainPath = "$ProjectRoot\MaiChartManager\AppMain.cs"
47+
$AppMainContent = Get-Content $AppMainPath -Raw
48+
49+
if ($Mode -eq "Canary") {
50+
$SourceVersion = $BuildVersion
51+
} else {
52+
$SourceVersion = $baseVer
53+
}
54+
55+
$AppMainContent = $AppMainContent -replace 'public const string Version = "[^"]+"', "public const string Version = ""$SourceVersion"""
56+
Set-Content $AppMainPath $AppMainContent -Encoding UTF8
57+
58+
59+
# ==========================================
60+
# 2. 清理环境
61+
# ==========================================
62+
Write-Host "Cleaning up..." -ForegroundColor Cyan
63+
$PackDir = "$PSScriptRoot\Pack"
64+
if (Test-Path $PackDir) { Remove-Item $PackDir -Recurse -Force }
65+
Remove-Item "$PSScriptRoot\*.appx" -ErrorAction SilentlyContinue
66+
Remove-Item "$PSScriptRoot\*.msix" -ErrorAction SilentlyContinue
67+
68+
# ==========================================
69+
# 3. 构建 AquaMai
70+
# ==========================================
71+
Write-Host "Building AquaMai..." -ForegroundColor Cyan
72+
Push-Location "$ProjectRoot\AquaMai"
73+
try {
74+
Stop-Process -Name "dotnet" -Force -ErrorAction SilentlyContinue
75+
dotnet cake
76+
77+
$TargetResDir = "$ProjectRoot\MaiChartManager\Resources"
78+
if (-not (Test-Path $TargetResDir)) { New-Item -ItemType Directory -Path $TargetResDir }
79+
Copy-Item "Output\AquaMai.dll" $TargetResDir -Force
80+
81+
# AquaMai 签名
82+
if (Get-Command "AquaMaiLocalBuild.exe" -ErrorAction SilentlyContinue) {
83+
Write-Host "Signing AquaMai.dll..." -ForegroundColor Cyan
84+
AquaMaiLocalBuild.exe "$TargetResDir\AquaMai.dll"
85+
} else {
86+
Write-Host "AquaMaiLocalBuild.exe not found, skipping AquaMai signing." -ForegroundColor Yellow
87+
}
88+
89+
} finally {
90+
Pop-Location
91+
}
92+
93+
# ==========================================
94+
# 4. 构建前端
95+
# ==========================================
96+
Write-Host "Building Frontend..." -ForegroundColor Cyan
97+
Push-Location "$ProjectRoot\MaiChartManager\Front"
98+
try {
99+
cmd /c pnpm build
100+
} finally {
101+
Pop-Location
102+
}
103+
104+
# ==========================================
105+
# 5. 发布主程序
106+
# ==========================================
107+
Write-Host "Publishing MaiChartManager..." -ForegroundColor Cyan
108+
Push-Location "$ProjectRoot"
109+
try {
110+
# Determine Configuration
111+
$ConfigName = if ($Mode -eq "Canary") { "Crack" } else { "Release" }
112+
Write-Host "Using Configuration: $ConfigName" -ForegroundColor Yellow
113+
114+
dotnet publish -p:Configuration=$ConfigName
115+
} finally {
116+
Pop-Location
117+
}
118+
119+
# ==========================================
120+
# 6. 准备打包目录
121+
# ==========================================
122+
Write-Host "Preparing Package Directory..." -ForegroundColor Cyan
123+
124+
# 复制 Base 资源
125+
Copy-Item "$PSScriptRoot\Base\*" $PackDir -Recurse -Force
126+
127+
# 复制 Canary Base 资源 (如果存在且是 Canary 模式)
128+
if ($Mode -eq "Canary") {
129+
$BaseCanary = "$PSScriptRoot\Base-Canary"
130+
if (Test-Path $BaseCanary) {
131+
Write-Host "Copying Canary assets..." -ForegroundColor Cyan
132+
Copy-Item "$BaseCanary\*" $PackDir -Recurse -Force
133+
}
134+
}
135+
136+
# ==========================================
137+
# 7. 修改 Manifest (仅 Canary)
138+
# ==========================================
139+
if ($Mode -eq "Canary") {
140+
Write-Host "Patching Manifest for Canary..." -ForegroundColor Cyan
141+
$ManifestPath = "$PackDir\AppxManifest.xml"
142+
143+
[xml]$xml = Get-Content $ManifestPath
144+
145+
# 命名空间管理器
146+
$ns = New-Object System.Xml.XmlNamespaceManager($xml.NameTable)
147+
$ns.AddNamespace("x", "http://schemas.microsoft.com/appx/manifest/foundation/windows10")
148+
$ns.AddNamespace("uap", "http://schemas.microsoft.com/appx/manifest/uap/windows10")
149+
$ns.AddNamespace("desktop", "http://schemas.microsoft.com/appx/manifest/desktop/windows10")
150+
$ns.AddNamespace("uap3", "http://schemas.microsoft.com/appx/manifest/uap/windows10/3")
151+
152+
# 修改 Identity
153+
$xml.Package.Identity.Name = $xml.Package.Identity.Name + ".Canary"
154+
$xml.Package.Identity.Publisher = $CanaryPublisher
155+
$xml.Package.Identity.Version = $BuildVersion
156+
157+
# 修改 Properties
158+
$xml.Package.Properties.DisplayName = "MaiChartManager (Canary)"
159+
$xml.Package.Properties.PublisherDisplayName = "凌莞"
160+
161+
# 修改 Applications
162+
foreach ($app in $xml.Package.Applications.Application) {
163+
if ($app.VisualElements) {
164+
$app.VisualElements.DisplayName = $app.VisualElements.DisplayName + " (Canary)"
165+
}
166+
167+
# 修改 CLI Alias: mcm.exe -> mcmc.exe
168+
$aliasNode = $app.SelectSingleNode(".//desktop:ExecutionAlias", $ns)
169+
if ($aliasNode) {
170+
$aliasNode.Alias = "mcmc.exe"
171+
}
172+
}
173+
174+
$xml.Save($ManifestPath)
175+
} else {
176+
# Release 模式也要更新 Version
177+
$ManifestPath = "$PackDir\AppxManifest.xml"
178+
[xml]$xml = Get-Content $ManifestPath
179+
$xml.Package.Identity.Version = $BuildVersion
180+
$xml.Save($ManifestPath)
181+
}
182+
183+
# ==========================================
184+
# 8. 生成 PRI 并打包
185+
# ==========================================
186+
Write-Host "Generating PRI and Packing..." -ForegroundColor Cyan
187+
Push-Location $PackDir
188+
try {
189+
Remove-Item "priconfig.xml" -ErrorAction SilentlyContinue
190+
Remove-Item "*.pri" -ErrorAction SilentlyContinue
191+
192+
makepri.exe createconfig /cf priconfig.xml /dq zh-CN
193+
makepri.exe new /pr . /cf .\priconfig.xml
194+
Remove-Item "priconfig.xml"
195+
196+
$OutputName = if ($Mode -eq "Canary") { "MaiChartManager_Canary_$BuildVersion.appx" } else { "Store64.appx" }
197+
$OutputAppx = "$PSScriptRoot\$OutputName"
198+
199+
makeappx pack /d . /p $OutputAppx
200+
} finally {
201+
Pop-Location
202+
}
203+
204+
# ==========================================
205+
# 9. 签名 (仅 Canary)
206+
# ==========================================
207+
if ($Mode -eq "Canary") {
208+
Write-Host "Signing Appx..." -ForegroundColor Cyan
209+
210+
$SignCmd = "D:\Sign\signcode.cmd"
211+
if (Test-Path $SignCmd) {
212+
# 直接调用 cmd 脚本
213+
& $SignCmd $OutputAppx
214+
Write-Host "Build & Sign Complete: $OutputAppx" -ForegroundColor Green
215+
} else {
216+
Write-Warning "Sign script not found at $SignCmd. Skipping signing."
217+
}
218+
} else {
219+
Write-Host "Build Complete: $OutputAppx" -ForegroundColor Green
220+
}

Packaging/make.cmd

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

Sitreamai.sln

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,42 +38,49 @@ Global
3838
{5633AACB-9089-497C-8596-2C27BEAD2201}.Release|x64.ActiveCfg = Release|Any CPU
3939
{5633AACB-9089-497C-8596-2C27BEAD2201}.Release|x64.Build.0 = Release|Any CPU
4040
{5633AACB-9089-497C-8596-2C27BEAD2201}.Crack|x64.ActiveCfg = Release|Any CPU
41+
{5633AACB-9089-497C-8596-2C27BEAD2201}.Crack|x64.Build.0 = Release|Any CPU
4142
{077998A7-9AD8-4F41-B93B-B63EFD19A550}.Debug|x64.ActiveCfg = Debug|Any CPU
4243
{077998A7-9AD8-4F41-B93B-B63EFD19A550}.Debug|x64.Build.0 = Debug|Any CPU
4344
{077998A7-9AD8-4F41-B93B-B63EFD19A550}.Release|x64.ActiveCfg = Release|Any CPU
4445
{077998A7-9AD8-4F41-B93B-B63EFD19A550}.Release|x64.Build.0 = Release|Any CPU
4546
{077998A7-9AD8-4F41-B93B-B63EFD19A550}.Crack|x64.ActiveCfg = Release|Any CPU
47+
{077998A7-9AD8-4F41-B93B-B63EFD19A550}.Crack|x64.Build.0 = Release|Any CPU
4648
{63138773-1F47-474C-9345-15EB6183ECC6}.Debug|x64.ActiveCfg = Debug|Any CPU
4749
{63138773-1F47-474C-9345-15EB6183ECC6}.Debug|x64.Build.0 = Debug|Any CPU
4850
{63138773-1F47-474C-9345-15EB6183ECC6}.Release|x64.ActiveCfg = Release|Any CPU
4951
{63138773-1F47-474C-9345-15EB6183ECC6}.Release|x64.Build.0 = Release|Any CPU
5052
{63138773-1F47-474C-9345-15EB6183ECC6}.Crack|x64.ActiveCfg = Release|Any CPU
53+
{63138773-1F47-474C-9345-15EB6183ECC6}.Crack|x64.Build.0 = Release|Any CPU
5154
{513B1851-4576-45EC-8F8E-400A38B05502}.Debug|x64.ActiveCfg = Debug|Any CPU
5255
{513B1851-4576-45EC-8F8E-400A38B05502}.Debug|x64.Build.0 = Debug|Any CPU
5356
{513B1851-4576-45EC-8F8E-400A38B05502}.Release|x64.ActiveCfg = Release|Any CPU
5457
{513B1851-4576-45EC-8F8E-400A38B05502}.Release|x64.Build.0 = Release|Any CPU
5558
{513B1851-4576-45EC-8F8E-400A38B05502}.Crack|x64.ActiveCfg = Release|Any CPU
59+
{513B1851-4576-45EC-8F8E-400A38B05502}.Crack|x64.Build.0 = Release|Any CPU
5660
{FDB88E51-0D73-47B9-A342-E574EC0BA583}.Debug|x64.ActiveCfg = Debug|Any CPU
5761
{FDB88E51-0D73-47B9-A342-E574EC0BA583}.Debug|x64.Build.0 = Debug|Any CPU
5862
{FDB88E51-0D73-47B9-A342-E574EC0BA583}.Release|x64.ActiveCfg = Release|Any CPU
5963
{FDB88E51-0D73-47B9-A342-E574EC0BA583}.Release|x64.Build.0 = Release|Any CPU
6064
{FDB88E51-0D73-47B9-A342-E574EC0BA583}.Crack|x64.ActiveCfg = Release|Any CPU
65+
{FDB88E51-0D73-47B9-A342-E574EC0BA583}.Crack|x64.Build.0 = Release|Any CPU
6166
{DF1536F9-3B06-4463-B654-4CC3E708B610}.Debug|x64.ActiveCfg = Debug|Any CPU
6267
{DF1536F9-3B06-4463-B654-4CC3E708B610}.Debug|x64.Build.0 = Debug|Any CPU
6368
{DF1536F9-3B06-4463-B654-4CC3E708B610}.Release|x64.ActiveCfg = Release|Any CPU
6469
{DF1536F9-3B06-4463-B654-4CC3E708B610}.Release|x64.Build.0 = Release|Any CPU
6570
{DF1536F9-3B06-4463-B654-4CC3E708B610}.Crack|x64.ActiveCfg = Release|Any CPU
71+
{DF1536F9-3B06-4463-B654-4CC3E708B610}.Crack|x64.Build.0 = Release|Any CPU
6672
{6B5E1F3E-D012-4CFB-A2FA-26A6CE06BE66}.Debug|x64.ActiveCfg = Debug|Any CPU
6773
{6B5E1F3E-D012-4CFB-A2FA-26A6CE06BE66}.Debug|x64.Build.0 = Debug|Any CPU
6874
{6B5E1F3E-D012-4CFB-A2FA-26A6CE06BE66}.Release|x64.ActiveCfg = Release|Any CPU
6975
{6B5E1F3E-D012-4CFB-A2FA-26A6CE06BE66}.Release|x64.Build.0 = Release|Any CPU
7076
{6B5E1F3E-D012-4CFB-A2FA-26A6CE06BE66}.Crack|x64.ActiveCfg = Release|Any CPU
77+
{6B5E1F3E-D012-4CFB-A2FA-26A6CE06BE66}.Crack|x64.Build.0 = Release|Any CPU
7178
{B53B0257-7EA2-432B-B43E-C6A463D18788}.Debug|x64.ActiveCfg = Debug|Any CPU
7279
{B53B0257-7EA2-432B-B43E-C6A463D18788}.Debug|x64.Build.0 = Debug|Any CPU
7380
{B53B0257-7EA2-432B-B43E-C6A463D18788}.Release|x64.ActiveCfg = Release|Any CPU
7481
{B53B0257-7EA2-432B-B43E-C6A463D18788}.Release|x64.Build.0 = Release|Any CPU
75-
{B53B0257-7EA2-432B-B43E-C6A463D18788}.Crack|x64.ActiveCfg = Debug|Any CPU
76-
{B53B0257-7EA2-432B-B43E-C6A463D18788}.Crack|x64.Build.0 = Debug|Any CPU
82+
{B53B0257-7EA2-432B-B43E-C6A463D18788}.Crack|x64.ActiveCfg = Crack|Any CPU
83+
{B53B0257-7EA2-432B-B43E-C6A463D18788}.Crack|x64.Build.0 = Crack|Any CPU
7784
EndGlobalSection
7885
GlobalSection(SolutionProperties) = preSolution
7986
HideSolutionNode = FALSE
294 KB
Binary file not shown.

0 commit comments

Comments
 (0)