From d729b35a810385b61bae6c9f323c744f492a0e2a Mon Sep 17 00:00:00 2001 From: PTKu <61538034+PTKu@users.noreply.github.com> Date: Thu, 15 Aug 2024 10:20:01 +0200 Subject: [PATCH] Add EnsureOutputFolder method and integrate it into EnsureCsProjFile Added a new private method `EnsureOutputFolder` that checks if the output folder specified by `AxSharpProject.OutputFolder` exists, and if not, creates it. This method then returns the path to the output folder. Modified the `EnsureCsProjFile` method to call the newly added `EnsureOutputFolder` method. This ensures that the output folder is created before proceeding with the rest of the method's logic, preventing potential errors related to missing directories. --- .../src/AXSharp.Cs.Compiler/CsProject.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/CsProject.cs b/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/CsProject.cs index 98a3669a..238847d1 100644 --- a/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/CsProject.cs +++ b/src/AXSharp.compiler/src/AXSharp.Cs.Compiler/CsProject.cs @@ -83,10 +83,21 @@ private static string GetExecutingAssemblyPath() } + private string EnsureOutputFolder() + { + if (!Directory.Exists(AxSharpProject.OutputFolder)) + { + Directory.CreateDirectory(AxSharpProject.OutputFolder); + } + + return AxSharpProject.OutputFolder; + } + private void EnsureCsProjFile() { if (AxSharpProject.AxProject.ProjectInfo.Name != null) { + EnsureOutputFolder(); string expectedCsProjFileFullPath = string.Empty; string expectedCsProjFile = string.Empty; if (string.IsNullOrEmpty(this.AxSharpProject.CompilerOptions?.ProjectFile))