Search code examples
asp.net-web-apiweb.config-transform

Web.config transformation does not take web.debug.config but uses default


dotnet publish seems not to take the existing web.debug.config.

Steps

  • Created a new project in VS 2022 (17.6.2), using 'ASP .NET Core Web API' as project template.
  • Did a dotnet publish from CLI and grabbed the default web.config from publish folder.
  • Then added a web.debug.config with same content as the default to the project root.
  • Within web.debug.config, added timeout value <aspNetCore requestTimeout="00:02:00" ....
  • When I do a dotnet publish again, the web.debug.config gets copied to the publish folder, default web.config is still there.
  • I would expect that there is a web.config with the content from my own web.debug.config.

I have played around with <CopyToOutputDirectory>Never</CopyToOutputDirectory> and <CopyToPublishDirectory>Never</CopyToPublishDirectory> resulting the file beeing copied or not, but without effect on the actual content of web.config.

What am I missing or is my expectation among Transforming Web.config wrong?
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/transform-webconfig?view=aspnetcore-7.0


Solution

  • My assumption was wrong:
    a web.debug.config does not replace the web.config but transform it using the xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" namespace and later its Locator and Transform attributes.