From bf3bc0913b37e77f5f3ef14f409b3feb794cc447 Mon Sep 17 00:00:00 2001 From: Justin Kotalik Date: Fri, 8 May 2020 08:13:04 -0700 Subject: [PATCH] Check for output type exe (#459) --- src/Microsoft.Tye.Core/ConfigModel/ConfigFactory.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.Tye.Core/ConfigModel/ConfigFactory.cs b/src/Microsoft.Tye.Core/ConfigModel/ConfigFactory.cs index e6f5a3f44..8f4342ee7 100644 --- a/src/Microsoft.Tye.Core/ConfigModel/ConfigFactory.cs +++ b/src/Microsoft.Tye.Core/ConfigModel/ConfigFactory.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; using System.Collections.Generic; using System.IO; using Microsoft.Tye.Serialization; @@ -68,7 +69,7 @@ private static ConfigApplication FromSolution(FileInfo file) // We want a *fast* heuristic that excludes unit test projects and class libraries without // having to load all of the projects. var launchSettings = Path.Combine(projectFile.DirectoryName, "Properties", "launchSettings.json"); - if (File.Exists(launchSettings)) + if (File.Exists(launchSettings) || ContainsOutputTypeExe(projectFile)) { var service = new ConfigService() { @@ -83,6 +84,14 @@ private static ConfigApplication FromSolution(FileInfo file) return application; } + private static bool ContainsOutputTypeExe(FileInfo projectFile) + { + // Note, this will not work if OutputType is on separate lines. + // TODO consider a more thorough check with xml reading, but at that point, it may be better just to read the project itself. + var content = File.ReadAllText(projectFile.FullName); + return content.Contains("exe", StringComparison.OrdinalIgnoreCase); + } + private static ConfigApplication FromYaml(FileInfo file) { using var parser = new YamlParser(file);