I added an existing ASP.Net web application project to my solution. In addition to the standard debug and release configurations this solution also has two custom configurations, SAT and UAT. For the new web application right clicking on Web.Config shows the context menu but the option for "Add Config Transform" is grayed out.
I'm at a loss. The new project is a web application. The Configuration Manager does not show the two custom configurations for this project but it does for the other projects. The project appears to have the correct entries in the solution file.
Thoughts?
You must first define the configurations in the Configuration Manager. To be sure you are bringing up the Configuration Manager, you can access it by going to: Build->Configuraton Manager
In the Active Solution Configuration dropdown, select <New...>
. Once you've added, you will then be able to "Add Config Transform".
Don't edit your solution file directly. It will only cause headaches.
As we work with PublishProfiles, for me the answer was right-clicking the relevant pubxml
file (found in the project folder Properties
subfolder PublishProfiles
) and then selecting Add Config Transform
. No managers needed ;).
In my case, in Visual Studio 2015, when I created a new solution based on a project template, Add Config Transform was greyed out - but for a different reason:
Clicking on "Show all files" revealed the files were already there - only hidden. Hence, the button was greyed out (because there is no need to add them as they are already there).
Click "Show all files" icon:
Now you can expand "Web.config":
Double click on any of the transform files (Web.Debug.config
or Web.Release.config
) to open and edit it.
Notes:
I did not want to add an additional configuration, just use Debug and Release. If you create one, select it, and the transform file does not exist yet, then the context menu item Add Config Transform is active and not greyed out.
If you want to create additional configuration transform files, keep in mind that in Visual Studio, config transforms are correlated with configurations. To add another transform, you need to add a new configuration first. To add another one, do the following: Via the configuration manager (the dropdown where you can select Debug or Release), add a new configuration first, e.g. myNewConfig. Then select myNewConfig. Now select Web.config in the Solution Explorer, right click and select in the context menu "Add Config Transform" - it will create Web.myNewConfig.config. Once it exists, the context menu will be grayed out again, because VS only allows one transform per configuration.
To get this working i had to add new property groups to my csproj file.
Add Config Transform was grayed out.
i added the following XML to my csproj and reloaded the project. then Add Config Transform was available. once selected my addition transforms were added
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'IAT_CMCD|AnyCPU'">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'UAT_CM|AnyCPU'">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>