From c4c97f7d3401de0e6b81be6995a79e06d4654cfa Mon Sep 17 00:00:00 2001 From: Buddhika Chathuranga Date: Mon, 10 Aug 2020 13:32:22 +0530 Subject: [PATCH] Remove recursive look for configurations file Remove trimming .vshost extension in executable file name --- src/Core/ServiceWrapper/Program.cs | 31 +++++++++--------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/Core/ServiceWrapper/Program.cs b/src/Core/ServiceWrapper/Program.cs index dcdc981..efc6a0d 100644 --- a/src/Core/ServiceWrapper/Program.cs +++ b/src/Core/ServiceWrapper/Program.cs @@ -664,32 +664,19 @@ namespace WinSW var executablePath = new DefaultWinSWSettings().ExecutablePath; var baseName = Path.GetFileNameWithoutExtension(executablePath); - if (baseName.EndsWith(".vshost")) - { - baseName = baseName.Substring(0, baseName.Length - 7); - } - var d = new DirectoryInfo(Path.GetDirectoryName(executablePath)); - while (true) + if (File.Exists(Path.Combine(d.FullName, baseName + ".xml"))) { - if (File.Exists(Path.Combine(d.FullName, baseName + ".xml"))) - { - return new ServiceDescriptor(baseName, d); - } - - if (File.Exists(Path.Combine(d.FullName, baseName + ".yml"))) - { - return new ServiceDescriptorYaml(baseName, d).Configurations; - } - - if (d.Parent is null) - { - throw new FileNotFoundException($"Unable to locate { baseName }.[xml|yml] file within executable directory or any parents"); - } - - d = d.Parent; + return new ServiceDescriptor(baseName, d); } + + if (File.Exists(Path.Combine(d.FullName, baseName + ".yml"))) + { + return new ServiceDescriptorYaml(baseName, d).Configurations; + } + + throw new FileNotFoundException($"Unable to locate { baseName }.[xml|yml] file within executable directory or any parents"); } private static void PrintHelp()