Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Project template for Visual Studio 2015

I am trying to create a project template for Visual Studio 2015. I created a ASP.NET 5 class library (under the web section of Visual studio 2015) and used the option File->Export template. When I tried to create project using the exported template, only the .xproj file gets created. The files within the template and the dependencies are not getting added. But the same procedure works fine for normal class library project. Am I missing something.?

like image 448
AnandhaSundari M Avatar asked Nov 24 '15 05:11

AnandhaSundari M


People also ask

How do I add a project template to Visual Studio?

Go to Documents\Visual Studio Version\Templates\ProjectTemplates and create a new folder to separate your template from the default templates of visual studio. You will see the newly created template as shown below. Give the name of the project and click on 'Ok' button.

How do I find the project template in Visual Studio?

For example, you can right-click the project > click properties > select Application and see(refer to) the related information, for example, Output type -- Windows Application, Console Application, Class Library… Or you can find some related information about the project type from items, files etc.


2 Answers

I found the way to do this. Open up the zipfile and edit the .vstemplate file. The line that is missing is

<CreateInPlace>true</CreateInPlace>

This line goes between

<TemplateData></TemplateData>

This solves the problem for .NET Core 1.0.1 Tooling Preview 2, VS2015 Update 3.

like image 107
Bebben Avatar answered Oct 07 '22 00:10

Bebben


In order to solve this, I had to extract the output zipfile, and edit the .vstemplate file.

Removing the TargetFileName attribute from the <Project> element under <TemplateContent> worked, and the new .xproj file was correctly named.

The relevant part of the .vstemplate file looked like this:

<TemplateContent>
  <Project TargetFileName="MyProject.xproj" File="MyProject.xproj" ReplaceParameters="true">

And I changed it to:

<TemplateContent>
  <Project File="MyProject.xproj" ReplaceParameters="true">

The inspiration for this came from looking at the ASP.NET 5 project templates, and specifically the empty web's .vstemplate file.

like image 43
Cameron Jeffers Avatar answered Oct 07 '22 01:10

Cameron Jeffers