diff --git a/src/Microsoft.Tye.Core/ConfigFileFinder.cs b/src/Microsoft.Tye.Core/ConfigFileFinder.cs index 30b9f195..bc5a2d31 100644 --- a/src/Microsoft.Tye.Core/ConfigFileFinder.cs +++ b/src/Microsoft.Tye.Core/ConfigFileFinder.cs @@ -8,7 +8,7 @@ namespace Microsoft.Tye { public class ConfigFileFinder { - private static readonly string[] FileFormats = new[] { "tye.yaml", "tye.yml", "docker-compose.yaml", "docker-compose.yml", "*.csproj", "*.fsproj", "*.sln" }; + private static readonly string[] FileFormats = { "tye.yaml", "tye.yml", "docker-compose.yaml", "docker-compose.yml", "*.csproj", "*.fsproj", "*.sln" }; public static bool TryFindSupportedFile(string directoryPath, out string? filePath, out string? errorMessage) { @@ -16,19 +16,19 @@ namespace Microsoft.Tye { var files = Directory.GetFiles(directoryPath, format); - if (files.Length == 1) + switch (files.Length) { - errorMessage = null; - filePath = files[0]; - return true; + case 1: + errorMessage = null; + filePath = files[0]; + return true; + case 0: + continue; } - if (files.Length > 1) - { - errorMessage = $"More than one matching file was found in directory '{directoryPath}'."; - filePath = default; - return false; - } + errorMessage = $"More than one matching file was found in directory '{directoryPath}'."; + filePath = default; + return false; } errorMessage = $"No project project file or solution was found in directory '{directoryPath}'.";