Web.config 转换选项呈灰色

发布于 2024-09-16 07:21:08 字数 77 浏览 5 评论 0原文

在 VS2010 中,当我右键单击 web.config 文件时,“添加配置转换”选项呈灰色。

知道我怎样才能把它拿回来吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

陌伤ぢ 2024-09-23 07:21:08

它呈灰色,因为所有列出的配置都已进行转换。

我看不到转换文件,因为 vb.net 以其无限的智慧决定不本地显示关联的配置文件。显然,除了选择“显示所有文件”才能查看它们之外别无选择。

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.

初与友歌 2024-09-23 07:21:08

人们还可以完全避免配置管理器对话框,而直接编辑项目文件,根据需要添加尽可能多的附加配置文件。

当使用更高级的配置转换工具(例如 CodeAssassin.ConfigTransform 或 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>

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>
请爱~陌生人 2024-09-23 07:21:08

如果您想真正看到“添加配置转换”已启用,请使用配置管理器添加新配置。或者删除任意配置文件 web.release.config 或 web.Debug.config。
这是 Visual Studio 的限制,每个环境都有一个配置文件。

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.

桃气十足 2024-09-23 07:21:08

对我有用的是右键单击发布配置文件并选择“添加配置转换”,然后我复制了用于 QA、UAT、生产等转换的现有代码。

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.

乖乖哒 2024-09-23 07:21:08

重新启动 Visual Studio 对我有用。我不会说它对每个人都有效,但它确实值得尝试。

我有 5 个配置,但只有 3 个转换文件。我没有处于调试模式,但该选项仍然呈灰色。

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.

呆萌少年 2024-09-23 07:21:08

在从配置管理器添加额外的配置后,我遇到了这个问题。

我必须删除它们,然后在 Visual Studio 启用“添加配置转换”之前重新添加它们,

我猜测 Web 项目中的这些配置在某些时候已被删除/损坏,并且需要重置。

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.

笑忘罢 2024-09-23 07:21:08

除了默认的调试和发布配置之外,我们的解决方案还包含 140 多个项目和超过 13 种不同的配置。我在该解决方案中的一个项目中遇到了同样的问题。添加配置转换项呈灰色,但我只有调试和发布 web.config 转换。我相信这是因为该项目可能是在创建所有自定义配置后添加到解决方案中的。

我进入配置管理器并观察到该项目没有所有其他可用配置。我必须通过指定名称来手动添加每个缺少的配置。完成后,“添加配置转换”即可使用。

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.

难忘№最初的完美 2024-09-23 07:21:08

如果您要通过配置管理器添加自定义配置,请务必在创建配置时选中“创建新项目配置”复选框(默认情况下未选中)。

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.

作业与我同在 2024-09-23 07:21:08

我也有同样的问题。我的解决方案是安装 SlowCheetah 添加另一个配置转换。很奇怪,但是效果很好。

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

黯淡〆 2024-09-23 07:21:08

我遇到过这样的情况:我有一个名为“Dev”的现有配置。 Web.config 下没有 Web.Dev.congig 文件,并且添加的菜单选项被禁用。

我删除了配置并再次将其添加回来。执行此操作后,它添加了一个新的 Web.Dev.config 文件并启用了“添加配置转换”菜单选项。我怀疑 csproj 文件中存在一些混乱。

看来 VS2015 中已经消除了一些这种混乱。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文