2using System.Collections.Generic;
5using System.Threading.Tasks;
7using Microsoft.Extensions.Logging;
8using Microsoft.Extensions.Options;
90 IOptions<GeneralConfiguration> generalConfigurationOptions,
91 ILogger<WindowsByondInstaller> logger)
95 generalConfiguration = generalConfigurationOptions?.Value ??
throw new ArgumentNullException(nameof(generalConfigurationOptions));
109 ArgumentNullException.ThrowIfNull(version);
111 supportsCli = version.Major >= 515 && version.Minor >= 1598;
112 return supportsCli ?
"dd.exe" :
"dreamdaemon.exe";
116 public override Task
InstallByond(Version version,
string path, CancellationToken cancellationToken)
118 var tasks =
new List<Task>
127 return Task.WhenAll(tasks);
131 public override async Task
UpgradeInstallation(Version version,
string path, CancellationToken cancellationToken)
133 ArgumentNullException.ThrowIfNull(version);
134 ArgumentNullException.ThrowIfNull(path);
146 Logger.LogInformation(
"BYOND Version {version} needs dd.exe added to firewall", version);
162 Logger.LogTrace(
"Disabling trusted prompts in {configFilePath}...", configFilePath);
180 Logger.LogTrace(
"DirectX already installed.");
184 Logger.LogTrace(
"Installing DirectX redistributable...");
196 noShellExecute:
true);
199 using (cancellationToken.Register(() => directXInstaller.Terminate()))
200 exitCode = await directXInstaller.Lifetime;
201 cancellationToken.ThrowIfCancellationRequested();
230 Logger.LogInformation(
"Adding Windows Firewall exception for {path}...", dreamDaemonPath);
236 $
"advfirewall firewall add rule name=\"TGS DreamDaemon\" program=\"{dreamDaemonPath}\" protocol=tcp dir=in enable=yes action=allow",
237 readStandardHandles:
true,
238 noShellExecute:
true);
241 using (cancellationToken.Register(() => netshProcess.Terminate()))
242 exitCode = await netshProcess.Lifetime;
243 cancellationToken.ThrowIfCancellationRequested();
246 "netsh.exe output:{newLine}{output}",
248 await netshProcess.GetCombinedOutput(cancellationToken));
IIOManager IOManager
Gets the IIOManager for the ByondInstallerBase.
readonly IFileDownloader fileDownloader
The IFileDownloader for the ByondInstallerBase.
ILogger< ByondInstallerBase > Logger
Gets the ILogger for the ByondInstallerBase.
const string BinPath
The path to the BYOND bin folder.
IByondInstaller for windows systems.
async Task SetNoPromptTrusted(string path, CancellationToken cancellationToken)
Creates the BYOND cfg file that prevents the trusted mode dialog from appearing when launching DreamD...
const string ByondDXDir
The directory that contains the BYOND directx redistributable.
override Task InstallByond(Version version, string path, CancellationToken cancellationToken)
Does actions necessary to get an extracted BYOND installation working. A Task representing the runnin...
override string PathToUserByondFolder
The path to the BYOND folder for the user.
bool installedDirectX
If DirectX was installed.
override string GetDreamDaemonName(Version version, out bool supportsCli)
Get the file name of the DreamDaemon executable. The file name of the DreamDaemon executable.
const string ByondNoPromptTrustedMode
Setting to add to ByondDreamDaemonConfigFilename to suppress an invisible user prompt for running a t...
override string ByondRevisionsUrlTemplate
override string DreamMakerName
Get the file name of the DreamMaker executable.
const string ByondConfigDirectory
Directory to byond installation configuration.
const string ByondDreamDaemonConfigFilename
BYOND's DreamDaemon config file.
readonly IProcessExecutor processExecutor
The IProcessExecutor for the WindowsByondInstaller.
async Task InstallDirectX(string path, CancellationToken cancellationToken)
Attempt to install the DirectX redistributable included with BYOND.
async Task AddDreamDaemonToFirewall(Version version, string path, CancellationToken cancellationToken)
Attempt to add the DreamDaemon executable as an exception to the Windows firewall.
readonly GeneralConfiguration generalConfiguration
The GeneralConfiguration for the WindowsByondInstaller.
readonly SemaphoreSlim semaphore
The SemaphoreSlim for the WindowsByondInstaller.
WindowsByondInstaller(IProcessExecutor processExecutor, IIOManager ioManager, IFileDownloader fileDownloader, IOptions< GeneralConfiguration > generalConfigurationOptions, ILogger< WindowsByondInstaller > logger)
Initializes a new instance of the WindowsByondInstaller class.
const string TgsFirewalledDDFile
The file TGS uses to determine if dd.exe has been firewalled.
override async Task UpgradeInstallation(Version version, string path, CancellationToken cancellationToken)
Does actions necessary to get upgrade a BYOND version installed by a previous version of TGS....
General configuration options.
bool SkipAddingByondFirewallException
If the netsh.exe execution to exempt DreamDaemon from Windows firewall should be skipped.
Operation exceptions thrown from the context of a Models.Job.
Async lock context helper.
static async ValueTask< SemaphoreSlimContext > Lock(SemaphoreSlim semaphore, CancellationToken cancellationToken)
Asyncronously locks a semaphore .
Interface for using filesystems.
string ResolvePath()
Retrieve the full path of the current working directory.
string ConcatPath(params string[] paths)
Combines an array of strings into a path.
Task CreateDirectory(string path, CancellationToken cancellationToken)
Create a directory at path .
Task< bool > FileExists(string path, CancellationToken cancellationToken)
Check that the file at path exists.
Task WriteAllBytes(string path, byte[] contents, CancellationToken cancellationToken)
Writes some contents to a file at path overwriting previous content.
Task< IProcess > LaunchProcess(string fileName, string workingDirectory, string arguments=null, string fileRedirect=null, bool readStandardHandles=false, bool noShellExecute=false)
Launch a IProcess.
ErrorCode
Types of Response.ErrorMessageResponses that the API may return.