Custom "One ASP.NET" Project Templates within Visual Studio 2013
Asked Answered
F

1

20

Goal:

Integrate project templates within Visual Studio 2013's "One ASP.NET" collection.

New ASP.NET Project with Fake Custom Template


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. From there I added my love and affection and used Export Template. The zip lands in 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. 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. Bummer. Even more odd, the template installs only to C# and not to its Web sub-folder.

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. This nothing to do with my goal really, but it seems to suggest that VS2013 does not honor some of the XML within .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.

The first tree held WebTemplate45 and its project WebApplication45Dev12.vstemplate illustrating the ProjectType and ProjectSubtype values mentioned above. Mimicing this did not change aything.

The second tree also held a WebTemplate45 with WebTemplate.vstemplate included. This one was was significantly different because its Type=ProjectGroup and it referenced a TemplateGroupID and curious WizardExtension tag that referenced the OneASPNetProjectTemplateWizard. My guess is this is the daddy template that displays those showen in the image displayed.


Question(s)

What does it take to deliver a project package in the "One ASP.Net" popup? Registry alterations? 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://www.asp.net/mvc/tutorials/mvc-4/custom-mvc-templates

Franni answered 25/3, 2014 at 22:25 Comment(0)
M
1

Have you seen the Hot Towel MVC sample from John Papa? 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:

<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

From the page:

The Type attribute of each element must be set to Microsoft.VisualStudio.Mvc.Template. This is a custom namespace that only the MVC project wizard understands.

Just adding the files to the VSIX is not sufficient to register the templates with the MVC wizard. You need to provide information such as the template name, description, supported view engines and programming language to the MVC wizard. This information is carried in custom attributes associated with the element for each vstemplate file.

Looking in extensions.vsixmanifest, I do indeed see <Asset ... ProjectType="MVC"... and the assets marked with Type="Microsoft.VisualStudio.Mvc.Template"

Missal answered 28/3, 2014 at 16:50 Comment(1)
That is for MVC4 and all the templates prior to the One ASP.Net style templating. Everything in the registry as well as on the file system is different. Play around with the .vstemplates installed with 2013 and you'll see what I'm experiencing. Everything changed. :)Franni

© 2022 - 2024 — McMap. All rights reserved.