Publish ASP.Net Core in a Windows Service with different environment

Viewed 431

I have managed to successfully publish a ASP.Net Core application and run it as a service on my local machine. What I want to know is how do I publish for my different appsettings.{environment}.json?

I have largely followed these docs for guidance which states that different environments can be set by setting the ASPNETCORE_URLS environment variable but then doesn't elaborate further. I did some digging online and found this stackoverflow thread which seemed promising. I tried to publish with an environment of Development with the following command

dotnet publish -c Release -o G:\Project\publish /p:EnvironmentName=Development

but it still used the appsettings.Production.json by default. The command successfully changed the web.config file to include the following

<environmentVariables>
      <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>

But the docs posted above also state that for the web SDK the web.config is unnecessary for a Windows Services app. How do I publish different environments to a Windows Service?

0 Answers
Related