Web.config transformation option is greyed out

前端 未结 10 1078
刺人心
刺人心 2021-02-04 23:32

In VS2010, when I right click on my web.config file the \"Add Config Transforms\" option is greyed out.

Any idea how I can get that back?

相关标签:
10条回答
  • 2021-02-04 23:50

    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.

    0 讨论(0)
  • 2021-02-04 23:55

    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.

    0 讨论(0)
  • 2021-02-04 23:56

    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.

    0 讨论(0)
  • 2021-02-04 23:59

    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>
    
    0 讨论(0)
提交回复
热议问题