2009-06-12 161 views

回答

28

在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

2

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

6

我遇到了这个和多种自定义模板的问题。每个模板(例如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> 
相关问题