我会一步一步解释:

  1. 我的一个项目里有5个工程, 我想用其中的4个去创建一个新的工具模版,我还想把他们都放到一个文件夹下面当我用这个模版创建新的工程时.注意我的初始化项目,我想把他们转换成一个模版(我不会用个"InstallerCreator"这个工程所以可以忽略它).
  2. 在vs中, go to File -> Export Template ... 然后会弹出一个对话框.
  3. 默认的"Project Template" 选择按钮会被选上,如果不是,请选上. 在下拉列表中,选择一个我们想导出为模版的工程
  1. 下一步的窗口中,写下你的模版介绍,你可以选择一个你想要的图标. 取消选择"Automatically import the template into visual studio"的配置,你也可以取消选择另外一个按钮,如果你不想马上看到你导出的模版目录, 然后选择Finish.
  1. 就这样我导出了四个工程当作模版, 如下图所示, 在我的电脑上文件夹是"C:\Users\ASUS\Documents\Visual Studio 2012\My Exported Templates"
  2. 现在打开VS中的File > New > Project, 然后弹出新的工程窗口
  3. 选择 Extensibility > VSIX Project, 把工程名命名为“MVCStarterKitInstaller” 然后点击OK.
  4. 在这个解决方案中增加另一个工程, 这个应该是一个C#类型的模版, 命名为"MVCStartKit" 然后点击OK                                                                                             
  5. 解压出了在第五步的所有4个工程模版的zip文件, 他们放到了 “MVCStarterKit”工程文件夹下.
  6. 更名解压出来的模版中.vstemplate的后缀的所有文件, 例如, 每个压缩包解压后默认名字为: "MyTemplate.vstemplate", 你应该把他们重命名为和工程相关的名字,如: "Domain.vstemplate".
  7. 如果你想在模版中增加任何nuget的包, 你需要在vstemplate的导出文件里面加上下面这段, 然后再解压.
  8. <WizardExtension>
    <Assembly>NuGet.VisualStudio.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
    <FullClassName>NuGet.VisualStudio.TemplateWizard</FullClassName>
    </WizardExtension>
    <WizardData>
    <packagesrepository="extension"
    repositoryId="MVCStarterKitInstaller.Proggasoft.3ca090ba-cf48-48cb-be9b-7c406a371af1">
    <packageid="jQuery"version="2.0.0"/>
    <packageid="jQuery.UI.Combined"version="1.8.20.1"/>
    <packageid="jQuery.Validation"version="1.9.0.1"/>
    <packageid="Microsoft.jQuery.Unobtrusive.Validation"version="2.0.30506.0"/>
    <packageid="Microsoft.Web.Infrastructure"version="1.0.0.0"/>
    <packageid="Modernizr"version="2.6.2"/>
    </packages>
    </WizardData>
  9. 确保所有解压出来的文件下面的文件的Build Action设置为Content.                                                                                                                                            
  10. 现在你只需要在"MVCStarterKit"中添加一个叫做"MVCStarterKit.vstemplate"的文件, 并加上对应的icon图标文件: __TemplateIcon.ico. 模版文件内容如下:
     <VSTemplateVersion="2.0.0"Type="ProjectGroup"
    xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
    <TemplateData>
    <Name>Asp.net MVC 3 Starter Kit</Name>
    <Description>A template for Asp.net MVC 3 projects</Description>
    <Icon>__TemplateIcon.ico</Icon>
    <ProjectType>CSharp</ProjectType>
    </TemplateData>
    <TemplateContent>
    <ProjectCollection>
    <SolutionFolderName="Domains">
    <ProjectTemplateLinkProjectName="Domain">
    Domain\Domain.vstemplate
    </ProjectTemplateLink>
    <ProjectTemplateLinkProjectName="Domain.Test">
    Domain.Test\DomainTest.vstemplate
    </ProjectTemplateLink>
    </SolutionFolder>
    <SolutionFolderName="Web">
    <ProjectTemplateLinkProjectName="Web">
    Web\Web.vstemplate
    </ProjectTemplateLink>
    <ProjectTemplateLinkProjectName="Web.Tests">
    Web.Tests\WebTests.vstemplate
    </ProjectTemplateLink>
    </SolutionFolder>
    </ProjectCollection>
    </TemplateContent>
    </VSTemplate>
  11. Please check in the “MVCStarterKit.vstemplate” that  “Domain” and “Domain.Test” is instructed to be inside “Domains” solution folder and “Web” and “Web.Tests” is instructed to be inside the “Web” solution folder when we use the starter kit to create a new project.
  12. Add reference of “MVCStarterKit” project in “MVCStarterKitInstaller” project and double click “source.extension.vsixmanifest”
  13. Type “Product name”, “Description”, “Author” in Metadata screen.
  14. In “Install targets” leave it as it is.
  15. In “Assets” tab, select Project template from drop down, then select “A project in this solution” from drop down and then select “MVCStarterKit” in drop down.
  16. In “Dependencies” leave it as it is.
  17. Now build the solution in the output you will see the path of the VSIX file.
  18. Go to that folder and you will find the VSIX file.
  19. Double click the file and press “Install”.
  20. Now if you go to create a new project, you will see our created template in the project templates.
  21. If you want to uninstall the template, go to : Tools > Extension and updates.
  22. Press Uninstall and it will be uninstalled.

Visual Studio 2013中用VSIX创建项目模版的更多相关文章

  1. Visual Studio 2013新建ASP.NET项目使用Empty模板,在页面中使用验证控件出错的解决方案

    Visual Studio 2013新建ASP.NET项目使用Empty模板,在页面中使用验证控件,运行页面,会出现如下的错误: 错误原因 VisualStudio 2012(或2013) WebFo ...

  2. Visual Studio 2013中的新项目对话框

    在Visual Studio 2013,我们推出了添加新的项目对话框. 此对话框取代了是曾在2012年这个的对话框作品,所有ASP.NET项目(MVC,Web窗体和Web API). 这就是我们如何提 ...

  3. 如何使用Visual Studio 2013 开发PHP5.6项目

    原文如何使用Visual Studio开发PHP项目 在windows下开发php除了记事本 DW 以及一帮Zend studio,Eclipse,NetBeans之流以外,个人感觉还是vsiual ...

  4. SharpDX初学者教程第1部分:在Visual Studio 2013中设置SharpDX项目

    原文 http://www.johanfalk.eu/blog/sharpdx-tutorial-part-1-setting-up-a-sharpdx-project-in-visual-studi ...

  5. 在Visual Studio 2013中编译libssh2项目

     一. 下载需要的外部包,并解压,下面给出的链接如果无法访问,就google搜索下载一下: •下载openssl •下载zlib 二.修改libssh2项目配置: 1.C/C++->Gene ...

  6. 在Visual Studio 2013 上开发Node.js程序

    [题外话] 最近准备用Node.js做些东西,于是找找看能否有Visual Studio上的插件以方便开发.结果还真找到了一个,来自微软的Node.js Tools for Visual Studio ...

  7. Visual Studio 2013创建自定义多项目模版

    首先附上效果图: 可以看到输入解决方案名称后,自动创建了我事先写好的架构,并且项目名及Server层名称都变了,并且依然保持了引用关系. 下面讲具体步骤: 第一步:建立解决方案,并将需要的代码全部写好 ...

  8. 在 Visual Studio 2013 中创建 ASP.NET Web 项目(0):专题导航 [持续更新中]

    写在前面的话 随着 Visual Studio 2013 的正式推出,ASP.NET 和 Visual Studio Web 开发工具 也发布了各自的最新版本. 新版本在构建 One ASP.NET ...

  9. 在 Visual Studio 2013 中创建 ASP.NET Web 项目(1):概述 - 创建 Web 应用程序项目

    注:本文是“在 Visual Studio 2013 中创建 ASP.NET Web 项目”专题的一部分,详情参见 专题导航 . 预备知识 本专题适用于 Visual Studio 2013 及以上版 ...

随机推荐

  1. MySQL 单表查询(Day42)

    阅读目录 一,查询语法 二,简单查询 三,where约束 四,having过滤 五,分组查询 group by 六,关键字的执行优先级 七,查询排列 order by 八,使用聚合函数查询 九,whe ...

  2. beego——模板处理

    beego的模板处理引擎采用的是Go内置的html/template包进行处理,而且beego的模板处理逻辑是采用了缓存编译方式, 也就是所有的模板会在beego应用启动的时候全部编译然后缓存在map ...

  3. Linux负载均衡--LVS(IPVS)

    一.LVS简介 LVS是Linux Virtual Server的简称,也就是Linux虚拟服务器, 是一个由章文嵩博士发起的自由软件项目,现在已经是 Linux标准内核的一部分.LVS是一种叫基于T ...

  4. MySQL-Last_Errno: 1594

    故障现象  :MySQL slave所在机器自动重启,启动MySQL后,查看主从信息如下: Error_code: 1594   mysql> show slave status \G . ro ...

  5. VRChat简易教程2-创建一个最基本的世界(world)

    一.准备工作 1 先确保你安装了unity并导入了sdk 教程:https://www.cnblogs.com/cation/p/10311702.html 2 按之前的教程新建一个project并导 ...

  6. [mongodb] MMAP 和wiredTiger 的比较

    mongodb 现在有两款存储引擎  MMAPv1 和 WireTiger,当然了除了这两款存储引擎还有其他的存储引擎了. 如: 内存引擎:现在的mongodb 版本中已经有了,主要的cache 服务 ...

  7. 《Maven实战》第6章 仓库

    6.1什么是Maven仓库? Maven仓库:存储所有Maven项目共享的构件的统一位置. Maven仓库的作用:Maven项目仅需声明依赖坐标,即可在需要的时候自动根据坐标找到仓库中的构件. 6.2 ...

  8. ThinkPHP关于模板的一些嵌套、IF判断使用

    > ##### 前言,现在有一组数据(涉及到3个数据表,order订单表,order_process办理流程表,process_status流程描述表),根据当前订单,展示相应信息 1.办理流程 ...

  9. Coldfusion8 读取HASH工具

    #!/usr/bin/env python #-*- coding:utf- -*- import sys import threading import urllib import httplib ...

  10. PHP5+APACHE2.2配置

    注意这里用的是PHP5.3版本 在Windows系统上使用Apache2.2上模块化安装PHP5.3 PHP5.3增加了一些功能,如namespace,静态迟绑定等. 本篇文章将帮您如何安装PHP5. ...