添加自定义视图引擎新建项目对话框? [英] Add custom viewengine to New project dialog?

查看:126
本文介绍了添加自定义视图引擎新建项目对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在创造MVC3一个新的项目,我有一个选项,选择自定义视图引擎。我之间的剃须刀 ASPX 的选择。有没有一种方法添加的星火应用于DropDownList的?

解决方案

简短的回答是:不,不是真的

长的答案是:是的,但是有一个问题,它需要一定的注册表编辑

New Project对话框是围绕第一选择projecttemplate,然后选择由模板支持的视图引擎的想法。

其他已成功地加入自己的东西这个窗口,所以我把通过的 ASP.NET MVC 3与xUnit.net TestProject的,另一个第三方扩展,并在注册表中扮演了一段时间。

首先,你必须创建一个ProjectTemplate的Visual Studio,从它可以生成一个干净的星火项目。为了完整起见,你可以通过创建一个新的剃刀的项目,它重新布线火花,然后导出使用文件菜单模板做到这一点。取消选中自动注册在VS.新出口箱我选择把我的安装简单,移动新模板到官方MVC3项目模板生活(对我来说,这是 C:\ Program Files文件(x86)的\微软的VisualStudio 10.0 \公用\ IDE \ ProjectTemplates \ CSHARP \ WEB )。然后从命令行运行devenv的/设置VS找到并注册新创建的模板。

自定义添加到新的对话窗口已经在这里补充:

<$p$p><$c$c>[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Mvc3\ProjectTemplates]  |  | - [MyOwnTemplate]       | - (REG_SZ)标题=模板标题       | - (REG_SZ)说明=说明在右边的盒子       | - [C#]           | - [星火]           | | - (REG_SZ)PATH =CSHARP \\网站           | | - (REG_SZ)模板=YourCustomCSharpSparkTemplate.zip           | | - (REG_DWORD)SupportsUnitTests = 1           | - [剃刀]               | - (REG_SZ)PATH =CSHARP \\网站               | - (REG_SZ)模板=YourCustomCSharpRazorTemplate.zip               | - (REG_DWORD)SupportsUnitTests = 0

如果你不是在64位安装,请从打开注册表节点Wow6432Node关键。

现在,当您重新启动VS和运行MVC3新注册的模板应该被列在那里新建项目对话框向导。当您选择自定义projecttemplate,你应该看到的视图引擎下拉菜单可显示星火作为当前视图引擎。

New Project对话框组模板由下ProjectTemplates顶键。由于MVC3不会在注册表中注册的默认模板,我们不知道在他们分组其中的关键,因此不能添加自己的ViewEngines这些。

When creating a new project for MVC3 I have an option to select a custom viewengine. I can choose between Razor and ASPX. Is there a way to add Spark to the dropdownlist?

解决方案

The short answer is: No, not really.

The long answer is: Yes, but there's a catch and it requires registry edits.

The New Project Dialog is built around the idea of selecting a projecttemplate first and then selecting a view-engine supported by that template.

Others have managed to add their own things to this window, so I took the hints offered by ASP.NET MVC 3 with xUnit.net Testproject, another 3rd party extension and played around in the registry for a while.

First you have to create a ProjectTemplate for visual studio from which it can generate a clean Spark project. For completeness sake, you can do this by creating a new Razor project, rewiring it for Spark and then exporting the template using the file menu. Uncheck the box to auto-register the new export in VS. I opted to keep my installation simple and moved the new template to where the official MVC3 project templates live (For me that was C:\Program Files (x86)\Microsoft VisualStudio 10.0\Common\IDE\ProjectTemplates\CSharp\Web). Then run "devenv /setup" from the commandline for VS to find and register the newly created template.

Custom additions to the New Dialogue Window have to be added here:

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Mvc3\ProjectTemplates]
 |
 |- [MyOwnTemplate]
      |- (REG_SZ)Title="Template title"
      |- (REG_SZ)Description="Description for the box in the right"
      |- [C#]
          |- [Spark]
          |   |- (REG_SZ)Path="CSharp\\Web"
          |   |- (REG_SZ)Template="YourCustomCSharpSparkTemplate.zip"
          |   |- (REG_DWORD)SupportsUnitTests=1
          |- [Razor]
              |- (REG_SZ)Path="CSharp\\Web"
              |- (REG_SZ)Template="YourCustomCSharpRazorTemplate.zip"
              |- (REG_DWORD)SupportsUnitTests=0

If you're not on a 64-bit installation, remove the Wow6432Node key from the opening registry node.

Now when you restart VS and run the New Project Dialog wizard for MVC3 the newly registered template should be listed in there. When you select your custom projecttemplate, you should see that the ViewEngine dropdown shows "Spark" as the current ViewEngine.

The New Project Dialog groups templates by the top-key under ProjectTemplates. Since MVC3 does not register its default templates in the registry we don't know under which key they are grouped and consequently cannot add our own ViewEngines to those.

这篇关于添加自定义视图引擎新建项目对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆