How can I prevent <aspNetCore /> tag from being auto-generated in web.config when having in-host processing enabled?

137 Views Asked by At

Recently, I was told by Microsoft that maybe in-host processing could solve some of my CPU issues (running .NET Core 2.2).

So I went into my .csproj and added:

<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>

Now, whenever building in Visual Studio, this gets forcefully inserted into my web.config:

<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" hostingModel="InProcess">
  <environmentVariables>
    <environmentVariable name="ASPNETCORE_HTTPS_PORT" value="44384" />
    <environmentVariable name="COMPLUS_ForceENC" value="1" />
    <!--<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" /> ALWAYS RE-APPEARS !!-->
    <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
  </environmentVariables>
</aspNetCore>

Notice the ASPNETCORE_ENVIRONMENT being set. If I uncomment it, or remove it, it will re-appear.

This is a problem because the web.config goes into my repo, then DevOps builds and publishes my app with the following App settings:

-ASPNETCORE_ENVIRONMENT Test

However, environmentVariable set in the web.config completely overrides this.

How can I prevent Visual Studio from messing with my web.config and not respecting my choices?

0

There are 0 best solutions below