Search code examples
azurevisual-studio.net-corewebdeploy

Prevent ASPNETCORE_ENVIRONMENT variable from being set in web publish


I'm trying to make use of deployment slots on Azure. I'd publish from Visual Studio to the "Staging" environment, make sure the staging environment was warmed up and functioning correctly, then use the azure "Swap" to make it live.

I have environment variables for the slots set in the Azure configuration, and I have "Deployment slot setting" checked for each.

However whenever I publish (to Staging) via web deploy, visual studio inserts the following into the web.config before publishing.

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

And after swapping, the live web.config file has the "Staging" entry.

Is there a way to prevent Visual Studio from inserting this value when publishing?


Solution

  • This worked. Added this to the csproj:

    <IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>