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(); });