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

Commit

Permalink
Check for output type exe (#459)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotalik authored May 8, 2020
1 parent c7a2b30 commit bf3bc09
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Microsoft.Tye.Core/ConfigModel/ConfigFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
{
Expand All @@ -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("<OutputType>exe</OutputType>", StringComparison.OrdinalIgnoreCase);
}

private static ConfigApplication FromYaml(FileInfo file)
{
using var parser = new YamlParser(file);
Expand Down

0 comments on commit bf3bc09

Please sign in to comment.