From d363f5e790772a97c3ebd5c61b232b3dce2ba2a3 Mon Sep 17 00:00:00 2001 From: Declan Smith Date: Sat, 20 Dec 2025 22:14:39 +1000 Subject: [PATCH] fix(workflows): optimize project file discovery logic Replaced `GetCurrentDirectory` calls with `AtomRootDirectory` for accurate root resolution. Enhanced file enumeration with filters for `.csproj` files and added `EnumerationOptions` to handle recursion, inaccessible paths, and exclusion of special directories. This improves performance and ensures reliable project path resolution. --- .../Generation/DevopsWorkflowWriter.cs | 11 +++++++++-- .../Generation/GithubWorkflowWriter.cs | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/DecSm.Atom.Module.DevopsWorkflows/Generation/DevopsWorkflowWriter.cs b/DecSm.Atom.Module.DevopsWorkflows/Generation/DevopsWorkflowWriter.cs index b22ae8e9..a28ae4ab 100644 --- a/DecSm.Atom.Module.DevopsWorkflows/Generation/DevopsWorkflowWriter.cs +++ b/DecSm.Atom.Module.DevopsWorkflows/Generation/DevopsWorkflowWriter.cs @@ -709,8 +709,15 @@ private static string FindProjectPath(IAtomFileSystem fileSystem, string project var projectPath = fileSystem .FileSystem .DirectoryInfo - .New(fileSystem.FileSystem.Directory.GetCurrentDirectory()) - .EnumerateFiles() + .New(fileSystem.AtomRootDirectory) + .EnumerateFiles("*.csproj", + new EnumerationOptions + { + IgnoreInaccessible = true, + MaxRecursionDepth = 4, + RecurseSubdirectories = true, + ReturnSpecialDirectories = false, + }) .FirstOrDefault(f => f.Name.Equals($"{projectName}.csproj", StringComparison.OrdinalIgnoreCase)); if (projectPath?.FullName is null) diff --git a/DecSm.Atom.Module.GithubWorkflows/Generation/GithubWorkflowWriter.cs b/DecSm.Atom.Module.GithubWorkflows/Generation/GithubWorkflowWriter.cs index 4eda211a..4803bb8c 100644 --- a/DecSm.Atom.Module.GithubWorkflows/Generation/GithubWorkflowWriter.cs +++ b/DecSm.Atom.Module.GithubWorkflows/Generation/GithubWorkflowWriter.cs @@ -797,8 +797,15 @@ private static string FindProjectPath(IAtomFileSystem fileSystem, string project var projectPath = fileSystem .FileSystem .DirectoryInfo - .New(fileSystem.FileSystem.Directory.GetCurrentDirectory()) - .EnumerateFiles() + .New(fileSystem.AtomRootDirectory) + .EnumerateFiles("*.csproj", + new EnumerationOptions + { + IgnoreInaccessible = true, + MaxRecursionDepth = 4, + RecurseSubdirectories = true, + ReturnSpecialDirectories = false, + }) .FirstOrDefault(f => f.Name.Equals($"{projectName}.csproj", StringComparison.OrdinalIgnoreCase)); if (projectPath?.FullName is null)