'Umbraco auto generate web.config if missing

We have a Umbraco website that references Umbraco.Web.UI,

<Reference Include="Umbraco.Web.UI, Version=8.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\packages\UmbracoCms.Web.8.12.2\lib\net472\Umbraco.Web.UI.dll</HintPath>
</Reference>

If we see the source code of Umbraco.Web.UI, then we see there is copy action that generates web.config from web.Template.config.

https://github.com/umbraco/Umbraco-CMS/blob/34e80d86e8c0b754f6b7a02e307f53cb32806bbe/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj#L369

But as far as I know if I just reference Umbraco.Web.UI.dll then these MSBuild actions in Umbraco.Web.UI.dll will not run.

My question is that how come web.config is generated if I build the project and web.config is missing.

The problem is that we have removed web.config from the repository and we wanna to understand how this web.config is generated so that we can modify it when we deploy.



Solution 1:[1]

So my csproj is using,

<Import Project="..\packages\UmbracoCms.8.12.2\build\UmbracoCms.targets"

and UmbracoCms.targets have the below action

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Imran Qadir Baksh - Baloch