Aspnetcore: Custom Web.config - aspNetCore section gets overwritten in Debug and Release mode

Created on 22 Mar 2018  路  15Comments  路  Source: dotnet/aspnetcore

After upgrading to Visual Studio 15.7 Preview 2 (added ANCM InProcess support for IIS Express), the aspNetCore section of a custom Web.config added to the project gets overwritten when starting IIS Express in Debug mode via Visual Studio UI. If hostingModel="InProcess" exists, this attribute gets removed so the application won't run in-process. Also, startupTimeLimit="3600" and requestTimeout="23:00:00" are added. Finally, environment variables ASPNETCORE_HTTPS_PORT and ASPNETCORE_ENVIRONMENT are added as well. Of course, deploying such a messed up Web.config file to the production server doesn't work out well.

Most helpful comment

@Elion, after upgrading to Visual Studio 15.9.0 the issue returned. After IIS Express start web.config gets overwritten with added <environmentVariable name="ASPNETCORE_HTTPS_PORT" value="44350" /> line. If this matters, I have next configuration in launchSettings.json:

"iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "https://localhost:44350/", "sslPort": 44350 } }

All 15 comments

@shirhatti / @jkotalik / @muratg - where should this issue get routed to?

@BillHiebert

Yeah, looks like a tooling bug.

@rockerinthelocker so you're not observing the overwrite in Release mode?

@muratg , Just checked and happens in release mode as well. Only publish is not affected.

Thanks @rockerinthelocker, yeah that's a little less surprising :)

@BillHiebert where is the best place to track this issue?

Upgraded to Visual Studio 15.6.4 yesterday and can confirm it is also happening on that version.

@postie77 - are you running against IIS or IIS Express? if IIS this is the expected behavior, though we are investigating trying to improve this. For IIS Express, if you remove the ANCM information from web.config, VS will write it into the applicationhost.config file that resides in the .vs\config. The timeouts are there to prevent ANCM from terminating the process while you are stepping through code in the debugger. The environment variables are added to support IIS where it is difficult to set environment variables on the W3WP.exe process.

@BillHiebert We're also seeing this on our side. We are often deploying (using publish - right click on the web project) on our local IIS. This then "transforms" our web.config with theses unwanted values. The devs usually forgets them and they get checked-in, then it moves "silently" into the other environments. Really annoying. Using VS 15.6.5.

Closing because it appears this issue is fixed. If anyone is still running into this, please let us know. Thanks!

@Elion, after upgrading to Visual Studio 15.9.0 the issue returned. After IIS Express start web.config gets overwritten with added <environmentVariable name="ASPNETCORE_HTTPS_PORT" value="44350" /> line. If this matters, I have next configuration in launchSettings.json:

"iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "https://localhost:44350/", "sslPort": 44350 } }

Similar issue which has been happening for a bit of time now, so not sure exactly which version this started happening in.

<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="#{ASPNETCORE_ENVIRONMENT}"/>

Is being overwritten with:

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

@ChristopherL-STCU, during investigation of other issue I stumbled on this comment, according to it, web.config will be rewritten any time, when it is present and it is different from what ANCM module is generating during startup. So, the possible solutions to keep web.config untouched by ANCM for now are:

  • remove ANCM information from web.config
  • or completely remove it from project and don't use IIS Express for development (instead use kestrel, etc)

    • or modify web.config to the state, that ANCM wants it to be and move your custom part to other file (for example transformation file) and apply it before your main replacement involved (Octopus variable substitution, I guess)

@d-dizhevsky thanks for the info and tips. And yes, it's an Octopus substitution variable.

@ChristopherL-STCU, you mentioned other person, but anyway, you are welcome :smile:.

Was this page helpful?
0 / 5 - 0 ratings