Visual Studio 2010制作和安装模板

问题描述:

我正在使用F#,我发现可用的模板有点稀疏,因为我喜欢,我想做更多。我会怎么做呢?另外,我将它们安装后如何安装这些模板?Visual Studio 2010制作和安装模板

这是MSDN的模板文章。希望这是类似的:

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

+0

谢谢!这指出我在正确的方向! – RCIX 2009-06-12 04:39:51

在Visual Studio中的路径,你会发现默认的模板,这是一组zip文件时得到扩展到模板CACH。

它们存储在

  • 项模板 - %VSInstallDir%\Common7\IDE\ItemTemplates\
  • 项目模板 - %VSInstallDir%\Common7\IDE\ProjectTemplates\

提取的{{.zip文件}}的问题,并与修改的内容重新压缩将更新模板。您还可以将这些文件复制到%USERPROFILE%\Documents\Visual Studio 2010中的相应模板文件夹之一。

有关构建模板的信息,请参阅MSDN上的Visual Studio Templates

然后你需要告诉VS重建缓存。

  1. 打开Visual Studio命令行shell
  2. 执行devenv /installvstemplates

您还可以使用“导出模板...”向导从文件菜单,但是导出模板失去原有的内容,作为if声明。

+5

忘了这一点,我意识到我只是意识到我需要用管理员权限启动控制台......呃! – 2010-02-05 13:45:42

+0

我运行devenv/installvstemplates,然后visual studio模板丢失。出现错误消息后,我只能看到2-3个模板。 – 2012-11-29 11:49:42

我想尝试http://msdn.microsoft.com/en-us/library/ms185291.aspx - 这似乎是一个很好的起点,至少。

就可以得到完整的示例实现的位置:Multi-Project Templates with Wizard: Visual Studio 2010 Sample

我失踪了SharePoint 2010和MOSS 2007模板在Visual Studio 2010开发工具,我的SharePoint安装之后。我重新安装了VS并发现它们可用。它看起来像安装SharePoint的先决条件,由于某些原因,我错过了安装的模板。

您可以下载和安装VS 2010 SDK(或VS 2010 SP1 SDK),其中包含新的项目模板,如项模板模板和项目模板模板(我不知道是否有版本更早版本的VS以及这些模板是否仅适用于C#)。

的Visual Studio 2010 SP1 SDK: http://www.microsoft.com/download/en/details.aspx?id=21835

的Visual Studio 2010 SDK: http://www.microsoft.com/download/en/details.aspx?id=2680

我遇到了这个和多种自定义模板的问题。每个模板(例如vstemplate + cs文件)应该位于它自己的zip文件中。如果你把几个放在同一个拉链里,它就不会拿起它们中的任何一个。

我还发现,如果你把它们放在:

$My Documents$\Visual Studio 2010\Templates\ItemTemplates

,那么你不会需要运行由Brett提到的命令(devenv的/ installvstemplates)。推测这只是在修改安装文件夹中现有的。

下面是我用敲了NUnit的测试样本:

代码文件(的.cs /相关扩展):

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using NUnit.Framework; 

namespace $rootnamespace$ 
{ 
    [TestFixture, Category("issue")] 
    public class $safeitemname$ 
    { 
     [SetUp] 
     public void Setup() 
     { 

     } 

     [Test] 
     public void Test() 
     { 

     } 
    } 
} 

模板文件(扩展名.vstemplate):

<VSTemplate Version="3.0.0" Type="Item" 
      xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" > 
    <TemplateData> 
    <DefaultName>ATest.cs</DefaultName> 
    <Name>NUnit test</Name> 
    <Description> 
     with [TestFixture] attribute set on class and one empty method 
     called Test that has [Test] attribute 
    </Description> 
    <ProjectType>CSharp</ProjectType> 
    <SortOrder>10</SortOrder> 
    <Icon>someIcon.ico</Icon> 
    </TemplateData> 
    <TemplateContent> 
    <References /> 
    <ProjectItem SubType="Code" TargetFileName="$fileinputname$.cs" 
       ReplaceParameters="true">TheCodeFile.cs</ProjectItem> 
    </TemplateContent> 
</VSTemplate>