diff --git a/src/Microsoft.Tye.Hosting/ProcessRunner.cs b/src/Microsoft.Tye.Hosting/ProcessRunner.cs index c87aa05b..ebb45391 100644 --- a/src/Microsoft.Tye.Hosting/ProcessRunner.cs +++ b/src/Microsoft.Tye.Hosting/ProcessRunner.cs @@ -149,8 +149,7 @@ namespace Microsoft.Tye.Hosting if (buildResult.ExitCode != 0) { - _logger.LogInformation("Building projects failed with exit code {ExitCode}: \r\n" + buildResult.StandardOutput, buildResult.ExitCode); - return; + throw new TyeBuildException($"Building projects failed with exit code {buildResult.ExitCode}: \r\n{buildResult.StandardOutput}"); } } diff --git a/src/Microsoft.Tye.Hosting/TyeBuildException.cs b/src/Microsoft.Tye.Hosting/TyeBuildException.cs new file mode 100644 index 00000000..7a7693cc --- /dev/null +++ b/src/Microsoft.Tye.Hosting/TyeBuildException.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// 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.Runtime.Serialization; + +namespace Microsoft.Tye.Hosting +{ + [Serializable] + internal class TyeBuildException : Exception + { + public TyeBuildException() + { + } + + public TyeBuildException(string? message) : base(message) + { + } + + public TyeBuildException(string? message, Exception? innerException) : base(message, innerException) + { + } + + protected TyeBuildException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } + } +} diff --git a/src/Microsoft.Tye.Hosting/TyeHost.cs b/src/Microsoft.Tye.Hosting/TyeHost.cs index 9ca2c2db..5df3ab32 100644 --- a/src/Microsoft.Tye.Hosting/TyeHost.cs +++ b/src/Microsoft.Tye.Hosting/TyeHost.cs @@ -91,7 +91,15 @@ namespace Microsoft.Tye.Hosting _logger.LogInformation("Dashboard running on {Address}", app.Addresses.First()); - await _processor.StartAsync(_application); + try + { + await _processor.StartAsync(_application); + } + catch (TyeBuildException ex) + { + _logger.LogError(ex.Message); + _lifetime.StopApplication(); + } if (_options.Dashboard) {