1

Given demo solution with two VSX-projects: 1. Add New Project -> Extensibility -> Item Template - "ItemTemplate1" 2. Add New Project -> Extensibility -> VSIX Project - "VSIXProject1"

I did no changes in "ItemTemplate1", so it constains default item template (ItemTemplate1.vstemplate):

<VSTemplate Version="3.0.0" Type="Item" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
  <Name>ItemTemplate1</Name>
  <Description>&lt;No description available&gt;</Description>
  <Icon>ItemTemplate1.ico</Icon>
  <TemplateID>e298765c-97b8-4f4c-9b7b-a6b368f914df</TemplateID>
  <ProjectType>CSharp</ProjectType>
  <RequiredFrameworkVersion>2.0</RequiredFrameworkVersion>
  <NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
  <DefaultName>Class.cs</DefaultName>
</TemplateData>
<TemplateContent>
    <References>
        <Reference>
            <Assembly>System</Assembly>
        </Reference>
    </References>
  <ProjectItem ReplaceParameters="true">Class.cs</ProjectItem>
</TemplateContent>
</VSTemplate>

In VSIXProject1 I only edited source.extension.vsixmanifest adding reference to ItemTemplates1 project. After this vsixmanifest contains only one content description:

<Content>
    <ItemTemplate>ItemTemplates</ItemTemplate>
</Content>

Then built it. In bin/debug I got VSIXProject1.vsix inside which I can see my item template in ItemTemplates\CSharp\1033\ItemTemplate1.zip file.

Everything looks great!

Except the fact it doesn't work. I run VSIXProject1.vsix, vsix installed (I can see it in the extension manager) but no any templates was copied to "C:\Users\{UserName}\Documents\Visual Studio 2010\Templates\ItemTemplates" !

4

2 回答 2

5

通过 VSIX 安装的模板不会安装到用户 Documents 文件夹中的 Templates 文件夹中。它们与该扩展的所有其他内容一起安装在 %LocalAppData%\Microsoft\VisualStudio\10.0\Extensions\<YourExtensionFolder> 下。(VSIX 安装基本上只是将 VSIX 解压缩到一个文件夹。)

当您尝试将新项目添加到 C# 项目时,您仍然应该能够看到该模板。

于 2010-09-01T22:26:59.080 回答
1

请查看下面的网站。它有助于解决我的问题。 http://silverlightdude.wordpress.com/2010/06/07/installing-the-prism-template-pack-for-visual-studio-2010/#comment-4

于 2011-04-22T02:02:08.017 回答