2009-06-12 163 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> 
相關問題