Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename web.config transforms

I am working in an ASP.net MVC 5 solution in Visual Studio 2015. I have the following web.config

web config transforms

How do I rename those to be

  • Web.Integration.config
  • Web.Staging.config
  • Web.Production.config

When I right-click on those, I don't get a rename option!

like image 435
J86 Avatar asked Jul 14 '16 10:07

J86


People also ask

What is Xdt transform in web config?

The xdt:Transform attribute value "SetAttributes" indicates that the purpose of this transform is to change attribute values of an existing element in the Web. config file.

How do I create a new transformation in web config?

If you have a web application project, Right-click on web. config and choose Add Config Transform. This will add any config transforms that are missing from your project based on build configurations (i.e. if you have Production and Staging build configs, both will get a transform added).

Where is web config file in Visual Studio 2022?

config file is located in the %SystemRoot%\Microsoft.NET\Framework\%VersionNumber%\CONFIG\ folder.


2 Answers

You can copy the files, rename them and manually edit the .csproj file to include them (replacing the generated ones) like below:

<Content Include="Web.Integration.config">
   <DependentUpon>Web.config</DependentUpon>
   <SubType>Designer</SubType>
 </Content>
 <Content Include="Web.Staging.config">
   <DependentUpon>Web.config</DependentUpon>
   <SubType>Designer</SubType>
 </Content>
 <Content Include="Web.Production.config">
   <DependentUpon>Web.config</DependentUpon>
   <SubType>Designer</SubType>
 </Content>

Unfortunatelly I did not find a way to acomplish this through visual studio.

like image 164
Mateusz Marczukiewicz Avatar answered Sep 18 '22 17:09

Mateusz Marczukiewicz


This is the third time I've set one of these up in a project and I get stuck every time. The key is that the config transform files are linked to the named build configurations.

If you go to Build > Configuration Manager... and select the Active solution configuration drop-down you can add new build names. Afterward you can right-click your web.config and Add Config Transform, which asks no questions and just creates one transform for each build.

Renaming an existing build didn't work, it still generated a transform with the original name, but you can delete builds or selectively delete the transform files.

like image 41
kitsu.eb Avatar answered Sep 20 '22 17:09

kitsu.eb