简体   繁体   English

Visual Studio 2015的项目模板

[英]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. 我正在尝试为Visual Studio 2015创建项目模板。我创建了一个ASP.NET 5类库(在Visual Studio 2015的Web部分下)并使用了File-> Export模板选项。 When I tried to create project using the exported template, only the .xproj file gets created. 当我尝试使用导出的模板创建项目时,只创建.xproj文件。 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.? 我错过了什么吗?

I found the way to do this. 我找到了这样做的方法。 Open up the zipfile and edit the .vstemplate file. 打开zip文件并编辑.vstemplate文件。 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. 这解决了.NET Core 1.0.1 Tooling Preview 2,VS2015 Update 3的问题。

In order to solve this, I had to extract the output zipfile, and edit the .vstemplate file. 为了解决这个问题,我不得不提取输出zipfile,并编辑.vstemplate文件。

Removing the TargetFileName attribute from the <Project> element under <TemplateContent> worked, and the new .xproj file was correctly named. <TemplateContent>下的<Project>元素中删除TargetFileName属性,并正确命名了新的.xproj文件。

The relevant part of the .vstemplate file looked like this: .vstemplate文件的相关部分如下所示:

<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 . 这方面的灵感来自于查看ASP.NET 5项目模板 ,特别是空网站的.vstemplate文件

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

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