简体   繁体   English

在Visual Studio 2013中自定义“一个ASP.NET”项目模板

[英]Custom “One ASP.NET” Project Templates within Visual Studio 2013

Goal: 目标:

Integrate project templates within Visual Studio 2013's "One ASP.NET" collection. 在Visual Studio 2013的“One ASP.NET”集合中集成项目模板。

带有假自定义模板的新ASP.NET项目


Background: 背景:

The "to be distributed" project began as a new ASP.NET Web Application project, using the Empty template and the MVC and Web API "folders and references" checked. “待分发”项目始于一个新的ASP.NET Web应用程序项目,使用Empty模板和MVC和Web API“文件夹和引用”进行检查。 From there I added my love and affection and used Export Template . 从那里我添加了我的爱和感情,并使用了导出模板 The zip lands in My Documents > Visual Studio 2013 > My Exported Templates . 该zip My Documents > Visual Studio 2013 > My Exported Templates位于My Documents > Visual Studio 2013 > My Exported Templates If you have Visual Studio install the template for you, a duplicate zip is placed within My Documents > Visual Studio 2013 > Templates > ProjectTemplates . 如果您有Visual Studio为您安装模板,则在“ My Documents > Visual Studio 2013 > Templates > ProjectTemplates放置一个重复的zip。 Here's where the problem begins... 这是问题的开始......


Issue: 问题:

In Visual Studio the template is found within the Visual C# tree branch, not a custom template within the ASP.NET Web Application template. 在Visual Studio中的模板是Visual C#树枝中发现的,而不是ASP.NET Web应用程序模板的自定义模板。 Bummer. 游民。 Even more odd, the template installs only to C# and not to its Web sub-folder. 更奇怪的是,模板仅安装到C#而不安装到其Web子文件夹。

MSDN documentation online mentioned a <ProjectSubType> within the .vstemplate file, which was empty when I investigated, but even explicitly adding Web did not change the UI location. 在线MSDN文档提到了.vstemplate文件中的<ProjectSubType> ,当我调查时它是空的,但即使显式添加Web也没有改变UI位置。 This nothing to do with my goal really, but it seems to suggest that VS2013 does not honor some of the XML within .vstemplate ? 这无关我的目标真的,但它似乎表明,VS2013不接受一些内部的XML的.vstemplate

More Info: 更多信息:

I started digging through the Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\IDE\\ProjectTemplates\\ and one of the oddball things I noticed was two separate "folder trees": {root}\\Web\\CSharp\\1033 and {root}\\CSharp\\Web\\1033 . 我开始挖掘Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\IDE\\ProjectTemplates\\ ,我注意到的一个奇怪的事情是两个单独的“文件夹树”: {root}\\Web\\CSharp\\1033{root}\\CSharp\\Web\\1033

The first tree held WebTemplate45 and its project WebApplication45Dev12.vstemplate illustrating the ProjectType and ProjectSubtype values mentioned above. 第一个树持有WebTemplate45及其项目WebApplication45Dev12.vstemplate说明上面提到的ProjectTypeProjectSubtype值。 Mimicing this did not change aything. 模仿这并没有改变任何东西。

The second tree also held a WebTemplate45 with WebTemplate.vstemplate included. 第二棵树还包含一个包含WebTemplate.vstemplate的WebTemplate.vstemplate This one was was significantly different because its Type=ProjectGroup and it referenced a TemplateGroupID and curious WizardExtension tag that referenced the OneASPNetProjectTemplateWizard . 这个是显着不同的,因为它的Type=ProjectGroup ,它引用了一个TemplateGroupID和引用OneASPNetProjectTemplateWizard好奇的WizardExtension标记。 My guess is this is the daddy template that displays those showen in the image displayed. 我猜这是爸爸模板,显示在显示的图像中显示的那些。


Question(s) 问题(S)

What does it take to deliver a project package in the "One ASP.Net" popup? 在“One ASP.Net”弹出窗口中提供项目包需要什么? Registry alterations? 注册表更改? VSIX? VSIX?

If it is not possible, is there anyway to clone the daddy window for all custom projects? 如果不可能,那么无论如何克隆所有自定义项目的爸爸窗口? Ex. 防爆。 imagine the window displayed with only a company's child templates listed. 想象一下显示的窗口只列出了公司的子模板。


References: 参考文献:

http://msdn.microsoft.com/en-us/library/xwkxbww4.aspx http://msdn.microsoft.com/en-us/library/xwkxbww4.aspx

http://www.asp.net/mvc/tutorials/mvc-4/custom-mvc-templates http://www.asp.net/mvc/tutorials/mvc-4/custom-mvc-templates

Have you seen the Hot Towel MVC sample from John Papa? 您是否看过John Papa的Hot Towel MVC样本? http://visualstudiogallery.msdn.microsoft.com/1eb8780d-d522-4dcf-bf56-56f0eab305c2 http://visualstudiogallery.msdn.microsoft.com/1eb8780d-d522-4dcf-bf56-56f0eab305c2

Opening the VSIX file in WinRAR, the key bits, in HotTowelSpa.2013.vsix\\ProjectTemplates\\HotTowelSpaProjectTemplate.cshtml\\HotTowelSpaProjectTemplate.cshtml.vstemplate , seem to be: 在WinRAR中打开VSIX文件, HotTowelSpa.2013.vsix\\ProjectTemplates\\HotTowelSpaProjectTemplate.cshtml\\HotTowelSpaProjectTemplate.cshtml.vstemplate的关键位似乎是:

<ProjectType>CSharp</ProjectType>
<ProjectSubType>Web</ProjectSubType>
<TemplateGroupID>Web</TemplateGroupID>

Edit 编辑

Indeed, it does look like you have to specify, specifically, that the project type is MVC: http://www.asp.net/mvc/tutorials/mvc-4/custom-mvc-templates 实际上,看起来你必须明确指出项目类型是MVC: http//www.asp.net/mvc/tutorials/mvc-4/custom-mvc-templates

From the page: 从页面:

The Type attribute of each element must be set to Microsoft.VisualStudio.Mvc.Template. 必须将每个元素的Type属性设置为Microsoft.VisualStudio.Mvc.Template。 This is a custom namespace that only the MVC project wizard understands. 这是一个只有MVC项目向导才能理解的自定义命名空间。

Just adding the files to the VSIX is not sufficient to register the templates with the MVC wizard. 只是将文件添加到VSIX不足以使用MVC向导注册模板。 You need to provide information such as the template name, description, supported view engines and programming language to the MVC wizard. 您需要向MVC向导提供模板名称,描述,支持的视图引擎和编程语言等信息。 This information is carried in custom attributes associated with the element for each vstemplate file. 此信息在与每个vstemplate文件的元素关联的自定义属性中携带。

Looking in extensions.vsixmanifest , I do indeed see <Asset ... ProjectType="MVC"... and the assets marked with Type="Microsoft.VisualStudio.Mvc.Template" 看看extensions.vsixmanifest ,我确实看到<Asset ... ProjectType="MVC"...以及标有Type="Microsoft.VisualStudio.Mvc.Template"的资产

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM