36 references to HostDefaults
Microsoft.AspNetCore (12)
ConfigureHostBuilder.cs (10)
64
var previousApplicationName = _configuration[
HostDefaults
.ApplicationKey];
67
var previousContentRootConfig = _configuration[
HostDefaults
.ContentRootKey];
68
var previousEnvironment = _configuration[
HostDefaults
.EnvironmentKey];
75
if (!string.Equals(previousApplicationName, _configuration[
HostDefaults
.ApplicationKey], StringComparison.OrdinalIgnoreCase))
77
throw 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.");
80
if (!string.Equals(previousContentRootConfig, _configuration[
HostDefaults
.ContentRootKey], StringComparison.OrdinalIgnoreCase)
81
&& !string.Equals(previousContentRoot, HostingPathResolver.ResolvePath(_configuration[
HostDefaults
.ContentRootKey]), StringComparison.OrdinalIgnoreCase))
83
throw 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.");
86
if (!string.Equals(previousEnvironment, _configuration[
HostDefaults
.EnvironmentKey], StringComparison.OrdinalIgnoreCase))
88
throw 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)
244
if (options.ContentRootPath is null && configuration[
HostDefaults
.ContentRootKey] is null)
261
new 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)
91
if (settings.ContentRootPath is null && Configuration[
HostDefaults
.ContentRootKey] is null)
147
optionList.Add(new KeyValuePair<string, string?>(
HostDefaults
.ApplicationKey, settings.ApplicationName));
152
optionList.Add(new KeyValuePair<string, string?>(
HostDefaults
.EnvironmentKey, settings.EnvironmentName));
157
optionList.Add(new KeyValuePair<string, string?>(
HostDefaults
.ContentRootKey, settings.ContentRootPath));
276
string? previousApplicationName = config[
HostDefaults
.ApplicationKey];
277
string? previousEnvironment = config[
HostDefaults
.EnvironmentKey];
278
string? previousContentRootConfig = config[
HostDefaults
.ContentRootKey];
288
if (!string.Equals(previousApplicationName, config[
HostDefaults
.ApplicationKey], StringComparison.OrdinalIgnoreCase))
290
throw new NotSupportedException(SR.Format(SR.ApplicationNameChangeNotSupported, previousApplicationName, config[
HostDefaults
.ApplicationKey]));
292
if (!string.Equals(previousEnvironment, config[
HostDefaults
.EnvironmentKey], StringComparison.OrdinalIgnoreCase))
294
throw new NotSupportedException(SR.Format(SR.EnvironmentNameChangeNotSupoprted, previousEnvironment, config[
HostDefaults
.EnvironmentKey]));
298
string? 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)
231
EnvironmentName = hostConfiguration[
HostDefaults
.EnvironmentKey] ?? Environments.Production,
232
ContentRootPath = ResolveContentRootPath(hostConfiguration[
HostDefaults
.ContentRootKey], AppContext.BaseDirectory),
235
string? applicationName = hostConfiguration[
HostDefaults
.ApplicationKey];
HostingHostBuilderExtensions.cs (3)
42
new KeyValuePair<string, string?>(
HostDefaults
.EnvironmentKey, environment)
62
new KeyValuePair<string, string?>(
HostDefaults
.ContentRootKey, contentRoot)
231
new KeyValuePair<string, string?>(
HostDefaults
.ContentRootKey, cwd),