Skip to content
This repository was archived by the owner on Nov 20, 2023. It is now read-only.

Commit bf3bc09

Browse files
authored
Check for output type exe (#459)
1 parent c7a2b30 commit bf3bc09

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Microsoft.Tye.Core/ConfigModel/ConfigFactory.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System;
56
using System.Collections.Generic;
67
using System.IO;
78
using Microsoft.Tye.Serialization;
@@ -68,7 +69,7 @@ private static ConfigApplication FromSolution(FileInfo file)
6869
// We want a *fast* heuristic that excludes unit test projects and class libraries without
6970
// having to load all of the projects.
7071
var launchSettings = Path.Combine(projectFile.DirectoryName, "Properties", "launchSettings.json");
71-
if (File.Exists(launchSettings))
72+
if (File.Exists(launchSettings) || ContainsOutputTypeExe(projectFile))
7273
{
7374
var service = new ConfigService()
7475
{
@@ -83,6 +84,14 @@ private static ConfigApplication FromSolution(FileInfo file)
8384
return application;
8485
}
8586

87+
private static bool ContainsOutputTypeExe(FileInfo projectFile)
88+
{
89+
// Note, this will not work if OutputType is on separate lines.
90+
// TODO consider a more thorough check with xml reading, but at that point, it may be better just to read the project itself.
91+
var content = File.ReadAllText(projectFile.FullName);
92+
return content.Contains("<OutputType>exe</OutputType>", StringComparison.OrdinalIgnoreCase);
93+
}
94+
8695
private static ConfigApplication FromYaml(FileInfo file)
8796
{
8897
using var parser = new YamlParser(file);

0 commit comments

Comments
 (0)