Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How to prevent web sdk from transforming web config file?


Asked by Ryder Fernandez on Dec 14, 2021 Web Services



To prevent the Web SDK from transforming the web.config file, use the <IsTransformWebConfigDisabled> property in the project file: When disabling the Web SDK from transforming the file, the processPath and arguments should be manually set by the developer. For more information, see ASP.NET Core Module.
Besides,
Transformations to the web.config file can be applied automatically when an app is published based on: These transformations occur for either of the following web.config generation scenarios: Generated automatically by the Microsoft.NET.Sdk.Web SDK. Build configuration transforms are run first.
Just so, The web.config files in application subfolders can override the settings of the web.config files in parent folders. In order to prevent parent config files to be overwritten, you need to configure IIS to ignore web.config files in application subfolders. An example for configuration hierarchy in IIS is below.
Keeping this in consideration,
Never remove the web.config file from a production deployment. If a web.config file isn't present in the project, the file is created with the correct processPath and arguments to configure the ASP.NET Core Module and moved to published output.
Likewise,
In an ASP.Net Core project you probably do not need to transform web.configs since supplying environment variables is handled by convention with appsettings. [Environment].json files. From the docs at https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.2: