16

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!

J86
  • 14,345
  • 47
  • 130
  • 228

4 Answers4

23

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.

  • make sure to check afterwards in the configuration manager that no projects have been 'unchecked' for build. This can waste a lot of time if you don't notice until later – Simon_Weaver May 17 '17 at 10:23
8

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.

kitsu.eb
  • 2,996
  • 1
  • 26
  • 28
4

If you are using the extension Configuration Transform go to Build > Configuration Manager and find the Configuration dropdown for the project of which you want to change the app config. You can then select the edit and rename the build configurations for that project. Then re-run the Configuration Transform tool and it will generate app configs using the names you provided in the build configuration settings. enter image description here

enter image description here

enter image description here

Nick Gallimore
  • 1,222
  • 13
  • 31
1

What I found worked for me is to just delete the Debug and Release, and then create new ones. Saved me a lot of worry with dangling references and build errors and the like

information_interchange
  • 2,538
  • 6
  • 31
  • 49