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

Check for output type exe #459

Merged
merged 3 commits into from
May 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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