Compare commits

..

4 Commits

Author SHA1 Message Date
d7e5f53e4f Fix SteamCMD args order + add quit arg 2023-07-10 01:46:28 -04:00
9b08b39a1f Switch from depot tool to SteamCMD 2023-07-10 01:25:31 -04:00
zznty
8011f9eed7 update harmony 2023-07-09 03:46:23 +07:00
1df791e7a8 Update for latest version, and have script compiler use Release x64 compilation 2023-07-07 22:37:52 -04:00
6 changed files with 34 additions and 40 deletions

View File

@@ -30,9 +30,8 @@ namespace Torch.Server
private bool _init;
private const string TOOL_DIR = "tool";
private const string TOOL_ZIP = "temp.zip";
private static readonly string TOOL_EXE = "DepotDownloader.exe";
private const string TOOL_ARGS = "-app 298740 -depot {1} -dir \"{0}\" -manifest {2}";
private static readonly int[] Depots = { 298741, 1004 };
private static readonly string TOOL_EXE = "steamcmd.exe";
private const string TOOL_ARGS = "+force_install_dir \"{0}\" +login anonymous +app_update 298740 +quit";
private TorchServer _server;
internal Persistent<TorchConfig> ConfigPersistent { get; }
@@ -131,7 +130,7 @@ namespace Torch.Server
public static async Task RunSteamCmdAsync(IConfiguration configuration)
{
var log = LogManager.GetLogger("SteamTool");
var log = LogManager.GetLogger("SteamCMD");
var path = configuration.GetValue<string>("steamToolPath") ?? ApplicationContext.Current.TorchDirectory
.CreateSubdirectory(TOOL_DIR).FullName;
@@ -141,49 +140,41 @@ namespace Torch.Server
Directory.CreateDirectory(path);
}
var steamCmdExePath = Path.Combine(path, TOOL_EXE);
if (!File.Exists(steamCmdExePath))
var toolExe = Path.Combine(path, TOOL_EXE);
if (!File.Exists(toolExe))
{
try
{
log.Info("Downloading Steam Tool.");
log.Info("Downloading SteamCMD.");
using (var client = new HttpClient())
await using (var file = File.Create(TOOL_ZIP))
await using (var stream = await client.GetStreamAsync("https://github.com/SteamRE/DepotDownloader/releases/download/DepotDownloader_2.4.7/depotdownloader-2.4.7.zip"))
await using (var stream = await client.GetStreamAsync("https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip"))
await stream.CopyToAsync(file);
ZipFile.ExtractToDirectory(TOOL_ZIP, path);
File.Delete(TOOL_ZIP);
log.Info("Steam Tool downloaded successfully!");
log.Info("SteamCMD downloaded successfully!");
}
catch (Exception e)
{
log.Error(e, "Failed to download Steam Tool, unable to update the DS.");
log.Error(e, "Failed to download SteamCMD, unable to update the DS.");
return;
}
}
log.Info("Checking for DS updates.");
foreach (var depot in Depots)
var steamCmdProc = new ProcessStartInfo(toolExe)
{
await DownloadDepot(depot);
}
Arguments = string.Format(TOOL_ARGS, configuration.GetValue("gamePath", "../")),
WorkingDirectory = path,
RedirectStandardOutput = true
};
var cmd = Process.Start(steamCmdProc)!;
async Task DownloadDepot(int depotId)
while (!cmd.HasExited)
{
var steamCmdProc = new ProcessStartInfo(steamCmdExePath)
{
Arguments = string.Format(TOOL_ARGS, configuration.GetValue("gamePath", "../"), depotId, "3111493184861426002"),
WorkingDirectory = path,
RedirectStandardOutput = true
};
var cmd = Process.Start(steamCmdProc)!;
while (!cmd.HasExited)
{
if (await cmd.StandardOutput.ReadLineAsync() is { } line)
log.Info(line);
}
if (await cmd.StandardOutput.ReadLineAsync() is { } line)
log.Info(line);
}
}
}

View File

@@ -153,8 +153,8 @@
},
"HarmonyX": {
"type": "Transitive",
"resolved": "2.10.2-prerelease.5",
"contentHash": "0ae0orZFSOMusmKRWfjcxeJY1rz04GMlTw4FRusljsT5UVZyToIBVZA1F8NVfD+zxCZZ++iNQth5EN0qsKtnLQ==",
"resolved": "2.10.2-prerelease.6",
"contentHash": "CPCUR/t5AQ5DDs40bTJ5OwUVTCoZONaJGbWKKjAOwg7c7Ct4KEbfybH6T+KvRGVjf5eN1oyGY5BN7EfWxUh9Xg==",
"dependencies": {
"MonoMod.RuntimeDetour": "25.0.0"
}
@@ -574,7 +574,7 @@
"type": "Project",
"dependencies": {
"ControlzEx": "[6.0.0, )",
"HarmonyX": "[2.10.2-prerelease.5, )",
"HarmonyX": "[2.10.2-prerelease.6, )",
"MahApps.Metro": "[2.4.9, )",
"Microsoft.CodeAnalysis.CSharp": "[4.6.0, )",
"Microsoft.CodeAnalysis.Common": "[4.6.0, )",

View File

@@ -214,7 +214,8 @@ public class ScriptCompilationManager : Manager
return null;
}
private readonly CSharpCompilationOptions _compilationOptions = new(OutputKind.DynamicallyLinkedLibrary);
private readonly CSharpCompilationOptions _compilationOptions = new(OutputKind.DynamicallyLinkedLibrary,
optimizationLevel: OptimizationLevel.Release, platform: Platform.X64);
private readonly CSharpParseOptions _parseOptions = new(LanguageVersion.CSharp11, DocumentationMode.None);
private CSharpCompilation CreateCompilation(string assemblyFileName, IEnumerable<Script> scripts)

View File

@@ -24,7 +24,7 @@
<ItemGroup>
<PackageReference Include="ControlzEx" Version="6.0.0" />
<PackageReference Include="HarmonyX" Version="2.10.2-prerelease.5" />
<PackageReference Include="HarmonyX" Version="2.10.2-prerelease.6" />
<PackageReference Include="InfoOf.Fody" Version="2.1.1" PrivateAssets="all" />
<PackageReference Include="MahApps.Metro" Version="2.4.9" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.6.0" />

View File

@@ -124,7 +124,9 @@ namespace Torch
Managers.AddManager(sessionManager);
Managers.AddManager(new PatchManager(this));
Managers.AddManager(new FilesystemManager(this));
#if !DEBUG
Managers.AddManager(new UpdateManager(this));
#endif
Managers.AddManager(new EventManager(this));
#pragma warning disable CS0618
Managers.AddManager(Plugins);

View File

@@ -14,9 +14,9 @@
},
"HarmonyX": {
"type": "Direct",
"requested": "[2.10.2-prerelease.5, )",
"resolved": "2.10.2-prerelease.5",
"contentHash": "0ae0orZFSOMusmKRWfjcxeJY1rz04GMlTw4FRusljsT5UVZyToIBVZA1F8NVfD+zxCZZ++iNQth5EN0qsKtnLQ==",
"requested": "[2.10.2-prerelease.6, )",
"resolved": "2.10.2-prerelease.6",
"contentHash": "CPCUR/t5AQ5DDs40bTJ5OwUVTCoZONaJGbWKKjAOwg7c7Ct4KEbfybH6T+KvRGVjf5eN1oyGY5BN7EfWxUh9Xg==",
"dependencies": {
"MonoMod.RuntimeDetour": "25.0.0"
}