JD2022-TU1/main/tools/apps/TeaBox/Script/Build/Version/MakeXboxOnePackageCommand.cs

72 lines
No EOL
3 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using BetaVersionLauncher;
using TeaBox.Code;
using TeaBox.Macros;
namespace TeaBox.BuildVersion
{
public class MakeXboxOnePackageCommand : MakePackageCommand
{
public override string DefaultDiscLayout => "ChunkMapping.xml";
protected override void CopyExecutableFromOutput(IStep stepcontext)
{
// Exclude release engine files for final package and final engine for release package
var patterns = Variant == DevEnvBuildVariant.Final ? new[] { "durango_ua_engine_r" } : new[] { "durango_ua_engine_f" };
Func<string, bool> keepFunc = file => !patterns.Any(file.Replace('\\', '/').Contains);
stepcontext.LogMessage("== Executables copy step ==");
stepcontext.LogMessage($"Starting to copy engine from {EngineExecutable.DeliveredDirectory} to {CodeWorkingDirectory}");
RoboCopy.ReplicateDirectory(EngineExecutable.DeliveredDirectory, CodeWorkingDirectory, stepcontext, deleteMissingFiles:true, @where:keepFunc);
}
protected override void SetOnlineEnvironmentImpl()
{
// Environment none, uat are default ones, don't need to change anything on the disc layout
if (GameOnlineEnvironment == GameOnlineEnvironment.Default || GameOnlineEnvironment.ToString().ToLower() == "uat" || GameOnlineEnvironment.ToString().ToLower() == "")
{
Context.LogWarning($"Selected environment: - {GameOnlineEnvironment} - doesn't require any changes");
return;
}
base.SetOnlineEnvironmentImpl();
const string pattern = "SplashScreen.png";
var environmentString =
$"\t<FileGroup DestinationPath=\"\\\" SourcePath=\".\\\" Include=\"{Path.GetFileName(EnvironmentFile)}\" />";
UpdateDiscLayout(pattern, environmentString);
}
protected override IEnumerable<string> GetFilesList()
{
return new List<string> { $"appxmanifest_{Variant}.xml" };
}
protected override void PrePackageImpl()
{
PkgTool = XboxOneConstants.GetPackageTool();
base.PrePackageImpl();
var appxManifest = Path.Combine(WorkingDirectory, "appxmanifest.xml");
Context.AddStep("Creating appdata file",
new GenericCommand(PkgTool, $"appdata /f \"{appxManifest}\"").Execute);
}
protected override void GeneratePackageImpl()
{
base.GeneratePackageImpl();
var productId = XboxOneConstants.GetProductId(GameType);
var contentId = XboxOneConstants.GetContentId(Region);
Context.AddStep("Creating package",
new LogFilterCommand(PkgTool, $"pack {PkgFormat} /productid {productId} /contentid {contentId} /f \"{LayoutPath}\" /d \"{WorkingDirectory}\" /pd \"{OutputDirectory}\"")
.Execute);
}
}
}