From 28998239a65d5e73eca8f2963b66fcdc3f59d0ee Mon Sep 17 00:00:00 2001 From: MistEO Date: Thu, 1 Dec 2022 21:19:23 +0800 Subject: [PATCH] fix: Win CI error --- tools/MaaBuilder/Builder/BuildParameters.cs | 31 +++++++++++++-------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/tools/MaaBuilder/Builder/BuildParameters.cs b/tools/MaaBuilder/Builder/BuildParameters.cs index a9ccda5476..168c3007e9 100644 --- a/tools/MaaBuilder/Builder/BuildParameters.cs +++ b/tools/MaaBuilder/Builder/BuildParameters.cs @@ -23,17 +23,17 @@ public partial class Build { #region Nuke 默认全局参数 - [CI] readonly GitHubActions GitHubActions; - + [CI] private readonly GitHubActions GitHubActions; + public static bool IsReleaseSimulation { get; set; } - #endregion + #endregion Nuke 默认全局参数 public class BuildParameters { #region 方法 - static readonly Lazy GetVsPath = new(() => + private static readonly Lazy GetVsPath = new(() => { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) is false) { @@ -45,7 +45,7 @@ public partial class Build return string.IsNullOrWhiteSpace(vsDirectory) ? null : vsDirectory; }); - readonly Func GetMsBuildPath = vsPath => + private readonly Func GetMsBuildPath = vsPath => { var msBuildExe = Path.Combine(vsPath, @"MSBuild\Current\Bin\MSBuild.exe"); if (File.Exists(msBuildExe) is false) @@ -56,35 +56,41 @@ public partial class Build return File.Exists(msBuildExe) ? msBuildExe : null; }; - #endregion + #endregion 方法 // 工具链 public AbsolutePath MsBuildPath { get; } + public AbsolutePath VisualStudioPath { get; } // 仓库 public string MainRepo { get; } + public string MasterBranchRef { get; } public string DevBranchRef { get; } public string ReleaseTagRefPrefix { get; } // 路径 public AbsolutePath BuildOutput { get; } + public AbsolutePath ArtifactOutput { get; } public AbsolutePath MaaChangelogFile { get; } // 项目 public Project MaaCoreProject { get; } + public Project MaaWpfProject { get; } // 配置 public string BuildTime { get; } + public string CommitHash { get; } public string CommitHashFull { get; } public List Packages { get; } = null; // CI public bool IsGitHubActions { get; } + public bool IsPullRequest { get; } public bool IsWorkflowDispatch { get; } public bool IsPreRelease { get; } @@ -116,19 +122,19 @@ public partial class Build // 路径 BuildOutput = RootDirectory / "x64"; ArtifactOutput = RootDirectory / "artifacts"; - + MaaChangelogFile = RootDirectory / "CHANGELOG.md"; // 项目 var maaSolution = ProjectModelTasks.ParseSolution(RootDirectory / "MAA.sln"); Assert.True(maaSolution is not null, "无法载入 MAA.sln"); - MaaCoreProject = maaSolution.GetProject("MeoAssistant"); - MaaWpfProject = maaSolution.GetProject("MeoAsstGui"); + MaaCoreProject = maaSolution.GetProject("MaaCore"); + MaaWpfProject = maaSolution.GetProject("MaaWpfGui"); // 配置 CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("zh-Hans-CN"); BuildTime = DateTimeOffset.UtcNow.ToLocalTime().ToString("yyyy-MM-dd-HH-mm-ss"); - + CommitHash = GitTasks.GitCurrentCommit(); Assert.True(CommitHash is not null, "Commit Hash 为 Null"); CommitHashFull = CommitHash; @@ -148,7 +154,7 @@ public partial class Build } GhActionName = (ActionConfiguration)b.GitHubActions!.Workflow; Assert.True(GhActionName is not null, $"GitHub Actions Workflow 名 {b.GitHubActions.Workflow} 无法转换为 ActionConfiguration"); - + Assert.False(string.IsNullOrEmpty(b.GitHubActions.Ref), "Ref 为 Null"); GitHubPersonalAccessToken = Environment.GetEnvironmentVariable("PUBLISH_GH_PAT"); @@ -198,6 +204,7 @@ public partial class Build case "Reason": GhActionWdReason = v.ToString(); break; + case "ReleaseSimulation": var tn = v.ToString(); if (string.IsNullOrEmpty(tn) || tn == "none") @@ -207,7 +214,7 @@ public partial class Build IsReleaseSimulation = true; GhActionWdRsTagName = tn; - + break; } }