Unable to override IHostEnvironment.ApplicationName using env variables or the command line using ConfigureWebHost/Defaults
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Describe the bug
The generic web host always overrides the application name and sets it as the Startup type's assembly or the configure delegate's container type's assembly name. This means its impossible to override it from the outside. This may not be a big deal generally but with the `WebApplicationBuilder` and the `WebApplicationFactory`, we're currently using the command line args to specify any host configuration. This generally works for everything except the application name.
### To Reproduce
```C#
var host = Host.CreateDefaultBuilder(new[]{ "--applicationName=RandomName" })
.ConfigureWebHostDefaults(builder => builder.Configure(app => {}))
.Build();
Assert.Equal("RandomName", host.Services.GetService().ApplicationName);
```
This test will fail if the project name isn't RandomName.
cc @halter73
Contributor guide
Assessment
This issue has not been assessed yet.