Platform
- Windows
- ASP.NET Core 8.0
IDE
- Microsoft Visual Studio Community 2022
- Version 17.13.2
- VisualStudio.17.Release/17.13.2+35825.156
- Windows 10
Problem
I have a simple ASP.NET Core 8.0 web application (NOT using MVC or Razor), built using Visual Studio 2022 with C#.
I have two separate web app services running on Azure (Windows/IIS) - one for development and one for production. When publishing the web application to Azure (using Visual Studio), I needed the web.config file to contain different URL rewrite rules for IIS depending on the build configuration, i.e.:
For the Release build:
web.release.configwould be transformed toweb.configand then published to the Azure production app service.
For the Debug build:
web.configwould be published to the development app service.
I edited the project file and included the following task to perform web.config transformations:
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="Web_config_AfterBuild" AfterTargets="AfterBuild" Condition="Exists('web.$(Configuration).config')">
<Message Importance="high" Text="****> Transforming web.$(Configuration).config to web.config" />
<TransformXml Source="web.config" Destination="$(OutputPath)web.config" Transform="web.$(Configuration).config" />
</Target>
Everything works as it should when publishing to Azure.
A snapshot of the web application solution explorer is shown below:
Note that the web.release.config file is NOT stacked below the web.config file as it is in other web site projects in Visual Studio, i.e.: the snapshot below is from a different web site project (also in Visual Studio 2022):
Question
Is this normal behavior for the solution explorer in Visual Studio 2022?
That is, does Visual Studio solution explorer treat an ASP.NET Core web application project differently than a web site project?
For now, it seems to be the case, as I cannot find any way to get the web.{Configuration}.config files to be nested below the web.config file as it does in web site projects.
It is not a big issue, I was just looking for some clarification (or documentation) if this is "normal" behavior for Visual Studio as it seems somewhat confusing (to me) as why some project types stack files and others do not.
Thanks in advance.









web.configfile andweb.Release.configfile are nested.See this.