36 references to HostDefaults
Microsoft.AspNetCore (12)
ConfigureHostBuilder.cs (10)
64var previousApplicationName = _configuration[HostDefaults.ApplicationKey]; 67var previousContentRootConfig = _configuration[HostDefaults.ContentRootKey]; 68var previousEnvironment = _configuration[HostDefaults.EnvironmentKey]; 75if (!string.Equals(previousApplicationName, _configuration[HostDefaults.ApplicationKey], StringComparison.OrdinalIgnoreCase)) 77throw new NotSupportedException($"The application name changed from \"{previousApplicationName}\" to \"{_configuration[HostDefaults.ApplicationKey]}\". Changing the host configuration using WebApplicationBuilder.Host is not supported. Use WebApplication.CreateBuilder(WebApplicationOptions) instead."); 80if (!string.Equals(previousContentRootConfig, _configuration[HostDefaults.ContentRootKey], StringComparison.OrdinalIgnoreCase) 81&& !string.Equals(previousContentRoot, HostingPathResolver.ResolvePath(_configuration[HostDefaults.ContentRootKey]), StringComparison.OrdinalIgnoreCase)) 83throw new NotSupportedException($"The content root changed from \"{previousContentRoot}\" to \"{HostingPathResolver.ResolvePath(_configuration[HostDefaults.ContentRootKey])}\". Changing the host configuration using WebApplicationBuilder.Host is not supported. Use WebApplication.CreateBuilder(WebApplicationOptions) instead."); 86if (!string.Equals(previousEnvironment, _configuration[HostDefaults.EnvironmentKey], StringComparison.OrdinalIgnoreCase)) 88throw new NotSupportedException($"The environment changed from \"{previousEnvironment}\" to \"{_configuration[HostDefaults.EnvironmentKey]}\". Changing the host configuration using WebApplicationBuilder.Host is not supported. Use WebApplication.CreateBuilder(WebApplicationOptions) instead.");
WebApplicationBuilder.cs (2)
244if (options.ContentRootPath is null && configuration[HostDefaults.ContentRootKey] is null) 261new KeyValuePair<string, string?>(HostDefaults.ContentRootKey, cwd),
Microsoft.AspNetCore.Mvc.Testing (1)
WebApplicationFactory.cs (1)
168{ HostDefaults.ApplicationKey, typeof(TEntryPoint).Assembly.GetName()?.Name ?? string.Empty }
Microsoft.AspNetCore.Tests (4)
WebApplicationTests.cs (4)
1084{ HostDefaults.ApplicationKey, "myapp" } 1230{ HostDefaults.ApplicationKey, "appName" }, 1231{ HostDefaults.EnvironmentKey, "environmentName" }, 1232{ HostDefaults.ContentRootKey, Directory.GetCurrentDirectory() },
Microsoft.Extensions.Hosting (19)
HostApplicationBuilder.cs (12)
91if (settings.ContentRootPath is null && Configuration[HostDefaults.ContentRootKey] is null) 147optionList.Add(new KeyValuePair<string, string?>(HostDefaults.ApplicationKey, settings.ApplicationName)); 152optionList.Add(new KeyValuePair<string, string?>(HostDefaults.EnvironmentKey, settings.EnvironmentName)); 157optionList.Add(new KeyValuePair<string, string?>(HostDefaults.ContentRootKey, settings.ContentRootPath)); 276string? previousApplicationName = config[HostDefaults.ApplicationKey]; 277string? previousEnvironment = config[HostDefaults.EnvironmentKey]; 278string? previousContentRootConfig = config[HostDefaults.ContentRootKey]; 288if (!string.Equals(previousApplicationName, config[HostDefaults.ApplicationKey], StringComparison.OrdinalIgnoreCase)) 290throw new NotSupportedException(SR.Format(SR.ApplicationNameChangeNotSupported, previousApplicationName, config[HostDefaults.ApplicationKey])); 292if (!string.Equals(previousEnvironment, config[HostDefaults.EnvironmentKey], StringComparison.OrdinalIgnoreCase)) 294throw new NotSupportedException(SR.Format(SR.EnvironmentNameChangeNotSupoprted, previousEnvironment, config[HostDefaults.EnvironmentKey])); 298string? currentContentRootConfig = config[HostDefaults.ContentRootKey];
HostApplicationBuilderSettings.cs (1)
49/// the <see cref="HostApplicationBuilder.Environment"/> through the use of <see cref="HostDefaults"/> keys. Disposing the built
HostBuilder.cs (3)
231EnvironmentName = hostConfiguration[HostDefaults.EnvironmentKey] ?? Environments.Production, 232ContentRootPath = ResolveContentRootPath(hostConfiguration[HostDefaults.ContentRootKey], AppContext.BaseDirectory), 235string? applicationName = hostConfiguration[HostDefaults.ApplicationKey];
HostingHostBuilderExtensions.cs (3)
42new KeyValuePair<string, string?>(HostDefaults.EnvironmentKey, environment) 62new KeyValuePair<string, string?>(HostDefaults.ContentRootKey, contentRoot) 231new KeyValuePair<string, string?>(HostDefaults.ContentRootKey, cwd),