diff --git a/src/dotnet/commands/dotnet-run/LaunchSettings/LaunchSettingsManager.cs b/src/dotnet/commands/dotnet-run/LaunchSettings/LaunchSettingsManager.cs index dd27329c6..0fbb7f777 100644 --- a/src/dotnet/commands/dotnet-run/LaunchSettings/LaunchSettingsManager.cs +++ b/src/dotnet/commands/dotnet-run/LaunchSettings/LaunchSettingsManager.cs @@ -85,7 +85,7 @@ namespace Microsoft.DotNet.Tools.Run.LaunchSettings } catch (JsonException ex) { - return new LaunchSettingsApplyResult(false, string.Format(LocalizableStrings.UnexpectedExceptionProcessingLaunchSettings, ex.Message)); + return new LaunchSettingsApplyResult(false, string.Format(LocalizableStrings.DeserializationExceptionMessage, ex.Message)); } } diff --git a/src/dotnet/commands/dotnet-run/LaunchSettings/ProjectLaunchSettingsProvider.cs b/src/dotnet/commands/dotnet-run/LaunchSettings/ProjectLaunchSettingsProvider.cs index 033f04381..780870494 100644 --- a/src/dotnet/commands/dotnet-run/LaunchSettings/ProjectLaunchSettingsProvider.cs +++ b/src/dotnet/commands/dotnet-run/LaunchSettings/ProjectLaunchSettingsProvider.cs @@ -13,30 +13,23 @@ namespace Microsoft.DotNet.Tools.Run.LaunchSettings public LaunchSettingsApplyResult TryApplySettings(JObject document, JObject model, ref ICommand command) { - try + var config = model.ToObject(); + + //For now, ignore everything but the environment variables section + + foreach (var entry in config.EnvironmentVariables) { - var config = model.ToObject(); - - //For now, ignore everything but the environment variables section - - foreach (var entry in config.EnvironmentVariables) - { - string value = Environment.ExpandEnvironmentVariables(entry.Value); - //NOTE: MSBuild variables are not expanded like they are in VS - command.EnvironmentVariable(entry.Key, value); - } - - if (!string.IsNullOrEmpty(config.ApplicationUrl)) - { - command.EnvironmentVariable("ASPNETCORE_URLS", config.ApplicationUrl); - } - - return new LaunchSettingsApplyResult(true, null, config.LaunchUrl); + string value = Environment.ExpandEnvironmentVariables(entry.Value); + //NOTE: MSBuild variables are not expanded like they are in VS + command.EnvironmentVariable(entry.Key, value); } - catch (Exception ex) + + if (!string.IsNullOrEmpty(config.ApplicationUrl)) { - return new LaunchSettingsApplyResult(false, ex.Message); + command.EnvironmentVariable("ASPNETCORE_URLS", config.ApplicationUrl); } + + return new LaunchSettingsApplyResult(true, null, config.LaunchUrl); } private class ProjectLaunchSettingsModel diff --git a/src/dotnet/commands/dotnet-run/LocalizableStrings.cs b/src/dotnet/commands/dotnet-run/LocalizableStrings.cs index 7d0374957..bf700eece 100644 --- a/src/dotnet/commands/dotnet-run/LocalizableStrings.cs +++ b/src/dotnet/commands/dotnet-run/LocalizableStrings.cs @@ -50,5 +50,7 @@ namespace Microsoft.DotNet.Tools.Run public const string UnexpectedExceptionProcessingLaunchSettings = "An unexpected exception occurred while processing launch settings:\n{0}"; public const string LaunchProfilesCollectionIsNotAJsonObject = "The 'profiles' property of the launch settings document is not a JSON object."; + + public const string DeserializationExceptionMessage = "An error was encountered when reading launchSettings.json.\n{0}"; } }