fix: Win CI error

This commit is contained in:
MistEO
2022-12-01 21:19:23 +08:00
parent ef44e718cd
commit 28998239a6

View File

@@ -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<string> GetVsPath = new(() =>
private static readonly Lazy<string> 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<string, string> GetMsBuildPath = vsPath =>
private readonly Func<string, string> 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<Package> 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;
}
}