✨ 优化自动化打包流程与命令兼容性

本次提交包括以下更新:
- 优化 CommandCompat.cs 中 SetHandler 的反射调用逻辑,提升类型兼容性与健壮性
- INSISBuildCommand 支持 timestamp=latest 自动查找最新发布目录,简化打包流程
- MSIXHelper.cs 新增多项 Windows 版本枚举,便于后续适配
- launchSettings.json 增加多种一键发布/打包/签名启动配置,提升运维效率
- DirectoryPackages 子模块标记为 dirty,提示有本地未提交更改
This commit is contained in:
LY
2026-02-02 13:59:27 +08:00
parent 0465f6f578
commit 64f60440a3
5 changed files with 56 additions and 8 deletions
@@ -25,11 +25,18 @@ static partial class CommandCompat
{
command.SetAction(parseResult =>
{
var values = options.Select(x =>
var values = options.Select(opt =>
{
var t = x.GetType().GetGenericArguments()[0];
var m = typeof(ParseResult).GetMethod(nameof(ParseResult.GetValue), BindingFlags.Instance | BindingFlags.Public).MakeGenericMethod(t);
return m.Invoke(parseResult, [x]);
var typeOpt = opt.GetType();
var typeArg = typeOpt.GetGenericArguments()[0];
var methodsGetValue = typeof(ParseResult).GetMethods(BindingFlags.Instance | BindingFlags.Public).Where(x =>
x.Name == nameof(ParseResult.GetValue)
&& x.GetParameters().FirstOrDefault()?.ParameterType.ToString() == typeof(Option<>).ToString())
.ToArray();
ArgumentNullException.ThrowIfNull(methodsGetValue);
var methodGetValue = methodsGetValue.Single().MakeGenericMethod(typeArg);
var arg = methodGetValue.Invoke(parseResult, [opt]);
return arg;
}).ToArray();
var result = @delegate.DynamicInvoke(values);
if (result is int code)
@@ -29,6 +29,31 @@ interface INSISBuildCommand : ICommand
hsm_sign = false; // hsm 目前无法映射到 CI VM 中
}
var projRootPath = ProjectPath_AvaloniaApp;
if (string.Equals("latest", timestamp, StringComparison.OrdinalIgnoreCase))
{
// 从发布文件夹中根据文件夹名称倒序查找最新的时间戳
var sPath = Path.Combine(projRootPath, "bin", PublishCommandArg.GetConfiguration(debug), "Publish");
var query = from p in Directory.EnumerateDirectories(sPath)
let s = Path.GetFileName(p).Split('_')
where s.Length > 2
let t = s.LastOrDefault()
let d = s[^2]
where !string.IsNullOrWhiteSpace(t) && !string.IsNullOrWhiteSpace(d)
let tN = ulong.TryParse(t, out var tUL) ? tUL : (ulong?)null
let dN = ulong.TryParse(d, out var dUL) ? dUL : (ulong?)null
where tN.HasValue && dN.HasValue
select new
{
tN,
dN,
p,
};
var latest = query.OrderByDescending(x => x.tN).ThenByDescending(x => x.dN).FirstOrDefault();
ArgumentNullException.ThrowIfNull(latest);
timestamp = $"{latest.dN}_{latest.tN}";
}
releaseTimestamp = timestamp;
var rootDirPath = Path.Combine(ProjectUtils.ProjPath, "..", "NSIS-Build");
@@ -51,7 +76,6 @@ interface INSISBuildCommand : ICommand
var info = DeconstructRuntimeIdentifier(rid);
if (info == default) continue;
var projRootPath = ProjectPath_AvaloniaApp;
var arg = SetPublishCommandArgumentList(debug, info.Platform, info.DeviceIdiom, info.Architecture);
var publishDir = Path.Combine(projRootPath, arg.PublishDir);
Console.WriteLine(publishDir);
@@ -6,9 +6,14 @@ static class MSIXHelper
{
enum WinVersion : ushort
{
_14393 = 14393,
_15063 = 15063,
_16299 = 16299,
_17134 = 17134,
W10_20H1 = 19041,
W11_21H2 = 22000,
W11_22H2 = 22621,
_26100 = 26100,
}
public static class MakePri
@@ -1,6 +1,6 @@
{
"profiles": {
"BD.WTTS.Client.Tools.Publish": {
"Publish(win-x64 hsm-sign)": {
"commandName": "Project",
"commandLineArgs": "run --rids win-x64 --hsm-sign --stm-upload",
"commandLineArgs_release": "run --rids win-x64 --hsm-sign --stm-upload",
@@ -9,6 +9,18 @@
"commandLineArgs_GenerateBridgeContentXml": "csproj --rids win-x64",
"commandLineArgs_TestUploadFile": "bs --type 2 --old \"C:\\Users\\Mossimo\\Desktop\\Steam++\\ms-test.steampp.net\""
},
"Publish(win-x64)": {
"commandName": "Project",
"commandLineArgs": "run --rids win-x64 --stm-upload"
},
"Publish Setup(win-x64 hsm-sign)": {
"commandName": "Project",
"commandLineArgs": "nsis --rids win-x64 --hsm-sign --t latest"
},
"Publish Setup(win-x64)": {
"commandName": "Project",
"commandLineArgs": "nsis --rids win-x64 --t latest"
},
"BD.WTTS.Client.Tools.Publish(TestUploadRc1)": {
"commandName": "Project",
"commandLineArgs": "bs --type 2 --old \"D:\\BuildTest\\rc1\""
@@ -93,4 +105,4 @@
"commandLineArgs": "bs --type 5 --old \"D:\\BuildTest\\rc4\" --new \"D:\\BuildTest\\pacth\\rc4-rc5\" --path \"D:\\BuildTest\\3.0.407.0\\3.0.507.0.dat\""
}
}
}
}