From a2634639902649ef8d2d709701e49e5bfab86f36 Mon Sep 17 00:00:00 2001 From: brdeyo Date: Tue, 3 Feb 2026 10:50:04 -0800 Subject: [PATCH] Ensure that the core/fundamental directories (e.g. logs, packages) are created up front to directory read/write issues. --- .../VirtualClient.Main/CommandBase.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/VirtualClient/VirtualClient.Main/CommandBase.cs b/src/VirtualClient/VirtualClient.Main/CommandBase.cs index abd6666c1b..a846f42f01 100644 --- a/src/VirtualClient/VirtualClient.Main/CommandBase.cs +++ b/src/VirtualClient/VirtualClient.Main/CommandBase.cs @@ -549,6 +549,9 @@ protected virtual IServiceCollection InitializeDependencies(string[] args) IKeyVaultManager keyVaultManager = new KeyVaultManager(); ApiClientManager apiClientManager = new ApiClientManager(this.ApiPorts); + // Ensure the core/fundamental directories exist. + this.CreateCoreDirectories(platformSpecifics, systemManagement.FileSystem); + // The Virtual Client supports a proxy API interface. When a proxy API is used, all dependencies/blobs will be download // through the proxy endpoint. All content/files will be uploaded through the proxy endpoint. All telemetry will be uploaded // the proxy endpoint (with the exception of file logging which remains as-is). This enables Virtual Client to support disconnected @@ -907,6 +910,29 @@ private static void AddSummaryLogging(List loggingProviders, st loggingProviders.Add(summaryLoggerProvider); } + private void CreateCoreDirectories(PlatformSpecifics platformSpecifics, IFileSystem fileSystem) + { + // Core Directories: + // - logs + // - packages + // - temp + + if (!fileSystem.Directory.Exists(platformSpecifics.LogsDirectory)) + { + fileSystem.Directory.CreateDirectory(platformSpecifics.LogsDirectory); + } + + if (!fileSystem.Directory.Exists(platformSpecifics.PackagesDirectory)) + { + fileSystem.Directory.CreateDirectory(platformSpecifics.PackagesDirectory); + } + + if (!fileSystem.Directory.Exists(platformSpecifics.TempDirectory)) + { + fileSystem.Directory.CreateDirectory(platformSpecifics.TempDirectory); + } + } + private string EvaluatePathReplacements(string path) { if (this.pathReplacements == null)