diff --git a/src/libraries/Microsoft.Extensions.Hosting/src/Internal/ConsoleLifetime.cs b/src/libraries/Microsoft.Extensions.Hosting/src/Internal/ConsoleLifetime.cs index 372a6146c55d25..5f23099082cbfe 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/src/Internal/ConsoleLifetime.cs +++ b/src/libraries/Microsoft.Extensions.Hosting/src/Internal/ConsoleLifetime.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.IO; using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; @@ -79,6 +80,13 @@ private void OnApplicationStarted() Logger.LogInformation("Application started. Press Ctrl+C to shut down."); Logger.LogInformation("Hosting environment: {EnvName}", Environment.EnvironmentName); Logger.LogInformation("Content root path: {ContentRoot}", Environment.ContentRootPath); + string contentRootFullPath = Path.GetFullPath(Environment.ContentRootPath); + + if (contentRootFullPath.Equals(System.Environment.CurrentDirectory, StringComparison.Ordinal) + || contentRootFullPath.Equals(AppContext.BaseDirectory, StringComparison.Ordinal)) + { + Logger.LogInformation("Current working directory is /. If Content root path is not set explicitly, then working directory is used by default."); + } } private void OnApplicationStopping()