From 5d562d0dfbb471d021bb247f45eda0cccbabeb4e Mon Sep 17 00:00:00 2001 From: Benji Huser Date: Mon, 13 Sep 2021 15:40:24 +0200 Subject: [PATCH] Handle missing directory when starting --- .../Services/AzureArtifactService.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/AzureArtifactManager/Services/AzureArtifactService.cs b/AzureArtifactManager/Services/AzureArtifactService.cs index 7d33e8e..e363d22 100644 --- a/AzureArtifactManager/Services/AzureArtifactService.cs +++ b/AzureArtifactManager/Services/AzureArtifactService.cs @@ -154,9 +154,19 @@ private async Task FetchArtifactTool(bool isRetry = false) var userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); var artifactToolFolder = Path.Join(userProfile, artifactToolParentFolder); - var artifactToolExecutable = Directory.GetFiles(artifactToolFolder, "artifacttool.exe", SearchOption.AllDirectories).FirstOrDefault(); + var artifactToolExecutable = string.Empty; - if (artifactToolExecutable == null) + try + { + + artifactToolExecutable = Directory.GetFiles(artifactToolFolder, "artifacttool.exe", SearchOption.AllDirectories).FirstOrDefault(); + } + catch (DirectoryNotFoundException) + { + artifactToolExecutable = null; + } + + if (string.IsNullOrEmpty(artifactToolExecutable)) { if (isRetry) {