开发者

Web.config transformation option is greyed out

In VS2010, when I right click o开发者_如何学运维n my web.config file the "Add Config Transforms" option is greyed out.

Any idea how I can get that back?


It was greyed out because there were already transforms for all of the listed configurations.

I couldn't see the transform files because vb.net in its infinite wisdom decided not to natively show the associated config files. Apparently there is no choice but to select "show all files" in order to see them.


One can also avoid the configuration manager dialog entirely and just directly edit the project file, adding as many additional config files as needed.

This is especially useful when using a more advanced config transformation tool like CodeAssassin.ConfigTransform or SlowCheetah.

<ItemGroup>
    <Content Include="web.config">
        <SubType>Designer</SubType>
    </Content>
    <Content Include="web.debug.local.config">
        <DependentUpon>web.config</DependentUpon>
    </Content>
    <Content Include="web.debug.cloudstaging.config">
        <DependentUpon>web.config</DependentUpon>
    </Content>
    <Content Include="web.release.cloudprod.config">
        <DependentUpon>web.config</DependentUpon>
    </Content>
</ItemGroup>


If you want to really see the "Add Config Transforms" enabled , then add a new configuration using the configurationManager. Or delete any of the configuration file web.release.config or web.Debug.config. This is Visual Studio restriction to have a single config file for each environment.


What worked for me is right clicking on the Publish profile and selecting "Add Config Transform", I then copied the existing code we had for transforms for QA, UAT, Production etc.


Restarting Visual Studio worked for me. I won't say it'll work for everyone, but it's certainly worth trying.

I had 5 configurations, but only 3 transform files. I was not in debug mode, but the option was still grayed out.


I had this issue after having already added extra Configurations from Configuration Manager.

I had to delete them, and re-add them before Visual Studio would enable "Add Config Transforms"

I'm guessing the configurations for these in the web project were removed/corrupted at some point, and it needed to be reset.


We have a solution with 140+ projects and over 13 different configurations, besides the default Debug and Release configurations. I ran into the same problem with one of my projects in that solution. The Add Config Transforms item was grayed out, yet I only had the Debug and Release web.config transforms. I believe this was because the project was probably added to the solution after all the custom configurations were created.

I went into the Configuration Manager and observed that the project didn't have all the other configurations available. I had to manually add each missing configuration by specifying and the name. Once that was done, the Add Config Transforms is available.


If it's a custom configuration you're adding via Configuration Manager, be sure to check the "Create new project configurations" checkbox (it's unchecked by default) when you create the configuration.


I had the same problem. My solution was to install SlowCheetah to add another config transformation. Strange, but it works very well.


I had the scenario where I had an existing configuration named "Dev". There was no Web.Dev.congig file under Web.config and the menu option to add was disabled.

I removed the configuration and added it back again. Upon doing this it added a new Web.Dev.config file and enabled the menu option to "Add config transform". I suspect there was some confusion going on in the csproj file.

It seems that some of this confusion has been cleared up in VS2015.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜