Search code examples
msbuildumbraco

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

  • 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