创建不会出现在 Web 项目下的 VSTemplates(仅在无特色的项目下)

发布于 2024-12-03 12:49:07 字数 616 浏览 3 评论 0原文

我们有一堆模板,其中一些仅在将新项目添加到 C# Web 应用程序项目时才可见(使用“Web”模板组 ID 进行过滤)。不过,我们的许多其他模板对于添加到 Web 项目没有意义(它们旨在添加到标准 C# 类库项目)。当我向 C# Web 应用程序项目添加新项目时,我想阻止显示这些模板。

我不确定这是否可行。我知道相反的情况也是可能的;创建显示在 Web 项目下的项目模板,但我希望我们的一些模板仅显示在无特色的 C# 项目上(而不 WebApp、WPF、工作流、 ETC)。

我查看了 HKCU\Software\Microsoft\VisualStudio\10.0Exp_Config\Projects{FAE04EC0-301F-11d3-BF4B-00C04F79EFBC} (原味的 C# 项目类型注册)下的注册表,可以看到它没有指定任何基于模板组 ID 进行过滤(看来这没有帮助)。有风味的项目子类型(例如工作流)似乎确实会过滤允许您添加的项目(例如,使用模板组 ID“WorkflowItemTemplateGroupID”),但无风味的项目似乎不会过滤其项目,因此不会过滤任何项目将 VisibleByDefault 设置为“false”的文件将始终不可见(因为它们无法指定模板组 ID)。

有办法做我想做的事吗?

We have a bunch of templates, some of which are only visible when adding a new item to a C# Web Application project (filtered using the "Web" template group ID). Many of our other templates, though, do not make sense to add to a web project (they are intended for adding to a standard C# class library project). I would like to prevent these templates from being displayed when I add a new item to a C# Web Application project.

I am not sure if this is possible to do. I know the inverse is possible; to create item templates that only show up under web projects, but I would like some of our templates to only show up on unflavored C# projects (not WebApp, WPF, Workflow, etc).

I took a look in the registry under HKCU\Software\Microsoft\VisualStudio\10.0Exp_Config\Projects{FAE04EC0-301F-11d3-BF4B-00C04F79EFBC} (the unflavoured C# project type registration), and I can see that it does not specify any filtering based on template group ID (so that's no help, it seems). Flavoured project subtypes, such as Workflow do seem to filter the items they allow you to add (using, for example, a template group ID of "WorkflowItemTemplateGroupID"), but it seems like unflavoured projects don't filter their items and therefore any items that have VisibleByDefault set to "false" will always be invisible (since they can't specify a template group ID).

Is there a way to do what I'm trying to do?

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

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

发布评论

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

评论(1

旧街凉风 2024-12-10 12:49:07

I figured out how to do this using the SVsRegisterNewDialogFilters service (which was the missing piece of the puzzle).

It enables you to supply an implementation of IVsFilterAddProjectItemDlg implementation which is called whenever the add-project-item dialog is invoked (regardless who invokes it). It is called with a different project type GUID for Web / Silverlight projects than for unflavoured C# projects (so I can simply filter out our various template directories .

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