From 11ca89bf37785168addde1aa47def66203d4d53f Mon Sep 17 00:00:00 2001 From: David Fowler Date: Wed, 25 Mar 2020 11:35:06 -0700 Subject: [PATCH] Print error if there are no runnable services in the application. (#193) --- src/tye/BuildHost.cs | 6 ++++++ src/tye/Program.DeployCommand.cs | 6 ++++++ src/tye/Program.RunCommand.cs | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/src/tye/BuildHost.cs b/src/tye/BuildHost.cs index cf13a794..0adb83e3 100644 --- a/src/tye/BuildHost.cs +++ b/src/tye/BuildHost.cs @@ -15,6 +15,12 @@ namespace Microsoft.Tye { var output = new OutputContext(console, verbosity); var application = await ApplicationFactory.CreateAsync(output, path); + + if (application.Services.Count == 0) + { + throw new CommandException($"No services found in \"{application.Source.Name}\""); + } + await ExecuteBuildAsync(output, application, environment: "production", interactive); } diff --git a/src/tye/Program.DeployCommand.cs b/src/tye/Program.DeployCommand.cs index 57a61a91..4db2946b 100644 --- a/src/tye/Program.DeployCommand.cs +++ b/src/tye/Program.DeployCommand.cs @@ -39,6 +39,12 @@ namespace Microsoft.Tye var output = new OutputContext(console, verbosity); var application = await ApplicationFactory.CreateAsync(output, path); + + if (application.Services.Count == 0) + { + throw new CommandException($"No services found in \"{application.Source.Name}\""); + } + await ExecuteDeployAsync(new OutputContext(console, verbosity), application, environment: "production", interactive, force); }); diff --git a/src/tye/Program.RunCommand.cs b/src/tye/Program.RunCommand.cs index bb44b1e0..4574ef42 100644 --- a/src/tye/Program.RunCommand.cs +++ b/src/tye/Program.RunCommand.cs @@ -5,6 +5,7 @@ using System; using System.CommandLine; using System.CommandLine.Invocation; +using System.CommandLine.IO; using System.IO; using System.Threading; using Microsoft.Tye.ConfigModel; @@ -76,6 +77,11 @@ namespace Microsoft.Tye InitializeThreadPoolSettings(serviceCount); + if (application.Services.Count == 0) + { + throw new CommandException($"No services found in \"{application.Source.Name}\""); + } + using var host = new TyeHost(application.ToHostingApplication(), args, debug); await host.RunAsync(); });