.net core 3.1 worker service - set EnvironmentName on publish
- Dominant language
- PowerShell
- Stars
- 22k
- Forks
- 4.9k
- Avg merge
- 5d 5h
- Merged PRs (30d)
- 29
Description
# Issue Title
Hello !
I'm trying to setup a worker service using the asp.net core 3.1 template provided by VS 2019 Enterprise.
# General
Steps to reproduce : Create a new project and run it : "Hosting Environment: Development", works as expected.

Create a FileSystem publish profile, and add `Test` to publish the worker to a testing environment for exemple

When launching the published version, HostingEnvironment is set to "Production", but i defined "Test" in the FolderProfile.pubxml

Is this a bug ? Or you don't publish worker services on another environments this way ?
I've also tried `dotnet publish /p:EnvironmentName=Test`, without success.
I also tried to generate manually a web.config file, containing
``, the worker service seems to ignore the web.config file.
Cannot run my application on custom environment, like Test or Staging !
PS : Works in Debug into VS, setting `DOTNET_ENVIRONMENT = Test` Environment variable

Thanks in advance
Edit : The final goal is to host this worker on a Windows Server 2012 R2 as a windows service (and managing different environments), `using Microsoft.Extensions.Hosting.WindowsServices, Version=3.1.1.0`
Contributor guide
Assessment
This issue has not been assessed yet.