Download LyraStarterGame/Build/Scripts/Deployment/LyraDeployment.EpicGameStore.cs from Alexhas2/unitysamples: direct link, hf CLI and curl.
- Browser
- Download file 8.06 kB
-
https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Build/Scripts/Deployment/LyraDeployment.EpicGameStore.cs
- Command line
-
hf download hf://datasets/Alexhas2/unitysamples/LyraStarterGame/Build/Scripts/Deployment/LyraDeployment.EpicGameStore.cs
-
curl -L -o LyraDeployment.EpicGameStore.cs https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Build/Scripts/Deployment/LyraDeployment.EpicGameStore.cs
8.06 kB
| // Copyright Epic Games, Inc.All Rights Reserved. | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Diagnostics; | |
| using System.IO; | |
| using System.Linq; | |
| using System.Net; | |
| using System.Text; | |
| using System.Threading; | |
| using System.Threading.Tasks; | |
| using AutomationTool; | |
| using FileLockInfo; | |
| using Microsoft.Extensions.Logging; | |
| using static AutomationTool.CommandUtils; | |
| namespace LyraDeployment | |
| { | |
| // Documentation | |
| // https://dev.epicgames.com/docs/services/en-US/EpicGamesStore/TechFeaturesConfig/BPTInstructionsSPT/index.html | |
| public class DeployToEpicGameStore : BuildCommand | |
| { | |
| static string DownloadBuildPackageTool() | |
| { | |
| // Download build package tool 1.5 | |
| string BuildPackageToolUrl = "https://launcher-public-service-prod.ol.epicgames.com/launcher/api/installer/download/BuildPatchTool.zip"; | |
| var BuildPathToolDownloadPath = CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, "BuildPatchTool.zip"); | |
| var BuildPathToolInstallPath = CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, "BPT"); | |
| var BuildPathToolPath = CommandUtils.CombinePaths(BuildPathToolInstallPath, "Engine/Binaries/Win64/BuildPatchTool.exe"); | |
| if (Directory.Exists(BuildPathToolInstallPath)) | |
| { | |
| Directory.Delete(BuildPathToolInstallPath, true); | |
| } | |
| using (var client = new WebClient()) | |
| { | |
| client.DownloadFile(BuildPackageToolUrl, BuildPathToolDownloadPath); | |
| } | |
| // Decompress the zip file to the target directory | |
| Logger.LogInformation("Decompressing to {BuildPathToolInstallPath}...", BuildPathToolInstallPath); | |
| CommandUtils.LegacyUnzipFiles(BuildPathToolDownloadPath, BuildPathToolInstallPath); | |
| CommandUtils.DeleteFile(BuildPathToolDownloadPath); | |
| // Make sure the file we need exists. | |
| CommandUtils.FileExists(false, BuildPathToolPath); | |
| return BuildPathToolPath; | |
| } | |
| public DeployToEpicGameStore() | |
| { | |
| } | |
| public override void ExecuteBuild() | |
| { | |
| Logger.LogInformation("*************************"); | |
| var LogInstanceId = Guid.NewGuid().ToString("N"); | |
| var LogFileDirectory = CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, "Saved", "Logs", "BuildPatchToolLog"); | |
| var BuildPathToolPath = DownloadBuildPackageTool(); | |
| string ArtifactId = ParseParamValue("ArtifactId", null); | |
| string BuildRoot = ParseParamValue("BuildRoot", null); | |
| string CloudDir = ParseParamValue("CloudDir", null); | |
| string BuildVersion = ParseParamValue("BuildVersion", null); | |
| string AppLaunch = ParseParamValue("AppLaunch", null); | |
| string AppArgs = ParseParamValue("AppArgs", null); | |
| string FileAttributeList = ParseParamValue("FileAttributeList", null); | |
| string FileIgnoreList = ParseParamValue("FileIgnoreList", null); | |
| string Platform = ParseParamValue("Platform", null); | |
| string Label = ParseParamValue("Label", null); | |
| string CommandLineFile = ParseParamValue("CommandLineFile", null); | |
| if (Directory.Exists(CloudDir)) | |
| { | |
| Directory.Delete(CloudDir, true); | |
| } | |
| // Verify nothing is locked before moving on. | |
| { | |
| Logger.LogInformation("Are Build Files Are Unlocked: Starting"); | |
| string[] FilesInBuildRoot = Directory.GetFiles(BuildRoot); | |
| // We need to make sure nothing is locking the build files. | |
| Stopwatch stopwatch = new Stopwatch(); | |
| stopwatch.Start(); | |
| while (stopwatch.Elapsed.TotalSeconds < 30) | |
| { | |
| List<Process> LockingProcesses = Win32Processes.GetProcessesLockingFiles(FilesInBuildRoot); | |
| if (LockingProcesses.Count > 0) | |
| { | |
| string LockingProcessesString = string.Join(", ", LockingProcesses.Select(c => c.ProcessName)); | |
| Logger.LogInformation("The following processes are locking files, {LockingProcessesString}", LockingProcessesString); | |
| Thread.Sleep(2000); | |
| } | |
| } | |
| stopwatch.Stop(); | |
| Logger.LogInformation("Are Build Files Are Unlocked: Done"); | |
| } | |
| Logger.LogInformation("Running BuildPatchTool Patch Generation on {ArtifactId}", ArtifactId); | |
| { | |
| string Args = ""; | |
| Args += Arg("mode", "PatchGeneration"); | |
| Args += Arg("ArtifactId", ArtifactId); | |
| Args += Arg("BuildRoot", Path.GetFullPath(BuildRoot)); | |
| Args += Arg("CloudDir", Path.GetFullPath(CloudDir)); | |
| Args += Arg("BuildVersion", BuildVersion); | |
| Args += Arg("AppLaunch", AppLaunch); | |
| Args += Arg("AppArgs", AppArgs); | |
| Args += Arg("FileAttributeList", FileAttributeList); | |
| Args += Arg("FileIgnoreList", FileIgnoreList); | |
| if (!String.IsNullOrEmpty(CommandLineFile)) | |
| { | |
| Args += " " + File.ReadAllText(Path.GetFullPath(CommandLineFile)); | |
| } | |
| // Add -stdout so that Horde gets logging. | |
| Args += Arg("stdout"); | |
| //string LogFileName = String.Concat("BuildPatchTool-PatchGeneration-", LogInstanceId); | |
| //string LogFilePath = Path.Combine(LogFileDirectory, String.Concat(LogFileName, ".stdout.log")); | |
| try | |
| { | |
| CommandUtils.RunAndLog(BuildPathToolPath, Args); | |
| } | |
| catch (AutomationException Ex) | |
| { | |
| Logger.LogError("{Text}", Ex.ToString()); | |
| //if (File.Exists(LogFilePath)) | |
| //{ | |
| // CommandUtils.LogInformation(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); | |
| // CommandUtils.LogInformation(File.ReadAllText(LogFilePath)); | |
| // CommandUtils.LogInformation(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); | |
| //} | |
| throw; | |
| } | |
| } | |
| Logger.LogInformation("BuildPatchTool Patch Generation Done!"); | |
| Logger.LogInformation("Running BuildPatchTool LabelBuild on {ArtifactId}", ArtifactId); | |
| { | |
| string Args = ""; | |
| Args += Arg("mode", "LabelBuild"); | |
| Args += Arg("ArtifactId", ArtifactId); | |
| Args += Arg("BuildRoot", Path.GetFullPath(BuildRoot)); | |
| Args += Arg("CloudDir", Path.GetFullPath(CloudDir)); | |
| Args += Arg("BuildVersion", BuildVersion); | |
| Args += Arg("Platform", Platform); | |
| Args += Arg("Label", Label); | |
| if (!String.IsNullOrEmpty(CommandLineFile)) | |
| { | |
| Args += " " + File.ReadAllText(Path.GetFullPath(CommandLineFile)); | |
| } | |
| // Add -stdout so that Horde gets logging. | |
| Args += Arg("stdout"); | |
| //string LogFileName = String.Concat("BuildPatchTool-LabelBuild-", LogInstanceId); | |
| //string LogFilePath = Path.Combine(LogFileDirectory, String.Concat(LogFileName, ".stdout.log")); | |
| try | |
| { | |
| CommandUtils.RunAndLog(BuildPathToolPath, Args/*, LogFilePath*/); | |
| } | |
| catch (AutomationException Ex) | |
| { | |
| Logger.LogError("{Text}", Ex.ToString()); | |
| //if (File.Exists(LogFilePath)) | |
| //{ | |
| // CommandUtils.LogInformation(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); | |
| // CommandUtils.LogInformation(File.ReadAllText(LogFilePath)); | |
| // CommandUtils.LogInformation(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); | |
| //} | |
| throw; | |
| } | |
| } | |
| Logger.LogInformation("BuildPatchTool Patch Generation Done!"); | |
| Logger.LogInformation("*************************"); | |
| } | |
| private static string Arg(string Key, string Value) | |
| { | |
| return Value == null ? "" : " -" + Key + "=\"" + Value + "\""; | |
| } | |
| private static string Arg(string Key, int Value) | |
| { | |
| return " -" + Key + "=" + Value; | |
| } | |
| private static string Arg(string Key, ulong Value) | |
| { | |
| return " -" + Key + "=" + Value; | |
| } | |
| private static string Arg(string Key) | |
| { | |
| return " -" + Key; | |
| } | |
| private static string Arg(string Key, IEnumerable<string> Value) | |
| { | |
| return " -" + Key + "=\"" + string.Join(",", Value) + "\""; | |
| } | |
| private static string CustomArgs<T>(string ArgName, List<KeyValuePair<string, T>> CustomArgs) | |
| { | |
| var Result = new StringBuilder(); | |
| if (CustomArgs != null) | |
| { | |
| foreach (var CustomArg in CustomArgs) | |
| { | |
| Result.Append(string.Format(" -{0}=\"{1}={2}\"", ArgName, CustomArg.Key, CustomArg.Value.ToString())); | |
| } | |
| } | |
| return Result.ToString(); | |
| } | |
| } | |
| } | |