2using System.Collections.Generic;
5using System.Threading.Tasks;
7using Microsoft.Extensions.Logging;
8using Microsoft.Extensions.Options;
107 IOptionsMonitor<GeneralConfiguration> generalConfigurationOptions,
108 IOptions<SessionConfiguration> sessionConfigurationOptions,
109 ILogger<WindowsByondInstaller> logger)
110 : base(ioManager, logger,
fileDownloader, generalConfigurationOptions)
113 sessionConfiguration = sessionConfigurationOptions?.Value ??
throw new ArgumentNullException(nameof(sessionConfigurationOptions));
115 var useServiceSpecialTactics = Environment.Is64BitProcess && Environment.UserName == $
"{Environment.MachineName}$";
117 var documentsDirectory = useServiceSpecialTactics
118 ? Environment.ExpandEnvironmentVariables(
"%SystemRoot%\\SysWOW64\\config\\systemprofile\\Documents")
119 : Environment.GetFolderPath(
120 Environment.SpecialFolder.MyDocuments,
121 Environment.SpecialFolderOption.DoNotVerify);
137 ArgumentNullException.ThrowIfNull(path);
148 Logger.LogInformation(
"BYOND Version {version} needs dd.exe added to firewall", version);
155 ArgumentNullException.ThrowIfNull(version);
156 ArgumentNullException.ThrowIfNull(fullDmbPath);
166 Logger.LogDebug(
"Adding .dmb ({dmbPath}) to {trustedFilePath}", fullDmbPath, trustedFilePath);
170 string trustedFileText;
171 var filePreviouslyExisted = await
IOManager.
FileExists(trustedFilePath, cancellationToken);
172 if (filePreviouslyExisted)
175 trustedFileText = Encoding.UTF8.GetString(trustedFileBytes);
176 trustedFileText = $
"{trustedFileText.Trim()}{Environment.NewLine}";
179 trustedFileText = String.Empty;
181 if (trustedFileText.Contains(fullDmbPath, StringComparison.Ordinal))
184 trustedFileText = $
"{trustedFileText}{fullDmbPath}{Environment.NewLine}";
186 var newTrustedFileBytes = Encoding.UTF8.GetBytes(trustedFileText);
188 if (!filePreviouslyExisted)
196 protected override ValueTask
InstallImpl(
EngineVersion version,
string path,
bool deploymentPipelineProcesses, CancellationToken cancellationToken)
200 var tasks =
new List<ValueTask>(3)
209 tasks.Add(firewallTask);
219 return supportsCli ?
"dd.exe" :
"dreamdaemon.exe";
226 var trustedFilePath =
231 Logger.LogTrace(
"Deleting trusted .dmbs file {trustedFilePath}", trustedFilePath);
232 yield
return trustedFilePath;
247 Logger.LogTrace(
"Disabling trusted prompts in {configFilePath}...", configFilePath);
265 Logger.LogTrace(
"DirectX already installed.");
269 Logger.LogTrace(
"Installing DirectX redistributable...");
282 noShellExecute:
true);
285 using (cancellationToken.Register(() => directXInstaller.Terminate()))
286 exitCode = (await directXInstaller.Lifetime).Value;
287 cancellationToken.ThrowIfCancellationRequested();
323 var ruleName = $
"TGS DreamDaemon {version}";
Information about an engine installation.
Version? Version
The System.Version of the engine. Currently only valid when Engine is EngineType.Byond.
Extension methods for the ValueTask and ValueTask<TResult> classes.
static async ValueTask WhenAll(IEnumerable< ValueTask > tasks)
Fully await a given list of tasks .
Base implementation of IEngineInstaller for EngineType.Byond.
readonly IFileDownloader fileDownloader
The IFileDownloader for the ByondInstallerBase.
const string CfgDirectoryName
The path to the cfg directory.
const string ByondBinPath
The path to the BYOND bin folder.
IOptionsMonitor< GeneralConfiguration > GeneralConfigurationOptions
The GeneralConfiguration IOptionsMonitor<TOptions> for the ByondInstallerBase.
void CheckVersionValidity(EngineVersion version)
Check that a given version is of type EngineType.Byond.
IIOManager IOManager
Gets the IIOManager for the EngineInstallerBase.
ILogger< EngineInstallerBase > Logger
Gets the ILogger for the EngineInstallerBase.
IEngineInstaller for windows systems.
const string ByondNoPromptTrustedMode
Setting to add to ByondDreamDaemonConfigFilename to suppress an invisible user prompt for running a t...
WindowsByondInstaller(IProcessExecutor processExecutor, IIOManager ioManager, IFileDownloader fileDownloader, IOptionsMonitor< GeneralConfiguration > generalConfigurationOptions, IOptions< SessionConfiguration > sessionConfigurationOptions, ILogger< WindowsByondInstaller > logger)
Initializes a new instance of the WindowsByondInstaller class.
override string GetDreamDaemonName(Version byondVersion, out bool supportsCli)
readonly IProcessExecutor processExecutor
The IProcessExecutor for the WindowsByondInstaller.
override ValueTask InstallImpl(EngineVersion version, string path, bool deploymentPipelineProcesses, CancellationToken cancellationToken)
const string ByondDreamDaemonConfigFilename
BYOND's DreamDaemon config file.
const string TgsFirewalledDDFile
The file TGS uses to determine if dd.exe has been firewalled.
async ValueTask AddDreamDaemonToFirewall(EngineVersion version, string path, bool deploymentPipelineProcesses, CancellationToken cancellationToken)
Attempt to add the DreamDaemon executable as an exception to the Windows firewall.
bool installedDirectX
If DirectX was installed.
override string DreamMakerName
override string PathToUserFolder
const string ByondConfigDirectory
Directory to byond installation configuration.
const string ByondDXDir
The directory that contains the BYOND directx redistributable.
static Version DDExeVersion
The first version of BYOND to ship with dd.exe on the Windows build.
override string OSMarkerTemplate
const string TrustedDmbFileName
The name of the list of trusted .dmb files in the user's BYOND cfg directory.
override IEnumerable< string > AdditionalCacheCleanFilePaths(string configDirectory)
List off additional file paths in the configDirectory to delete.An IEnumerable<T> of paths in config...
override async ValueTask UpgradeInstallation(EngineVersion version, string path, CancellationToken cancellationToken)
Does actions necessary to get upgrade a version installed by a previous version of TGS....
async ValueTask SetNoPromptTrusted(string path, CancellationToken cancellationToken)
Creates the BYOND cfg file that prevents the trusted mode dialog from appearing when launching DreamD...
async ValueTask InstallDirectX(string path, CancellationToken cancellationToken)
Attempt to install the DirectX redistributable included with BYOND.
readonly SessionConfiguration sessionConfiguration
The SessionConfiguration for the WindowsByondInstaller.
readonly SemaphoreSlim semaphore
The SemaphoreSlim for the WindowsByondInstaller.
override async ValueTask TrustDmbPath(EngineVersion version, string fullDmbPath, CancellationToken cancellationToken)
Add a given fullDmbPath to the trusted DMBs list in BYOND's config.A ValueTask representing the runn...
static readonly SemaphoreSlim UserFilesSemaphore
SemaphoreSlim for writing to files in the user's BYOND directory.
Configuration options for the game sessions.
bool ForceUseDreamDaemonExe
If set dd.exe will not be used on Windows systems in versions where it is present....
bool LowPriorityDeploymentProcesses
If the deployment DreamMaker and DreamDaemon instances are set to be below normal priority processes.
Operation exceptions thrown from the context of a Models.Job.
Helper class for interacting with the Windows Firewall.
static async ValueTask< int > AddFirewallException(IProcessExecutor processExecutor, ILogger logger, string exceptionName, string exePath, bool lowPriority, CancellationToken cancellationToken)
Add an executable exception to the Windows firewall.
Async lock context helper.
static async ValueTask< SemaphoreSlimContext > Lock(SemaphoreSlim semaphore, CancellationToken cancellationToken, ILogger? logger=null)
Asyncronously locks a semaphore .
Interface for using filesystems.
string ResolvePath()
Retrieve the full path of the current working directory.
ValueTask< byte[]> ReadAllBytes(string path, CancellationToken cancellationToken)
Returns all the contents of a file at path as a byte array.
string ConcatPath(params string[] paths)
Combines an array of strings into a path.
Task CreateDirectory(string path, CancellationToken cancellationToken)
Create a directory at path .
ValueTask WriteAllBytes(string path, byte[] contents, CancellationToken cancellationToken)
Writes some contents to a file at path overwriting previous content.
Task< bool > FileExists(string path, CancellationToken cancellationToken)
Check that the file at path exists.
ValueTask< IProcess > LaunchProcess(string fileName, string workingDirectory, string arguments, CancellationToken cancellationToken, IReadOnlyDictionary< string, string >? environment=null, string? fileRedirect=null, bool readStandardHandles=false, bool noShellExecute=false)
Launch a IProcess.
ErrorCode
Types of Response.ErrorMessageResponses that the API may return.