none
How TO: Use VSIX to install project template in sub-folder? RRS feed

  • Question

  • I have a project template that I've packaged up in a VSIX file.  I would like the template to show up in the "Windows" node under "Visual C#".  When I install the template, it shows up in "Visual C#" but not under "Windows".

    How do I tell the VSIX file to install the template under the correct folder?


    --- Thanks, Jeff (http://devmatter.blogspot.com/)
    Tuesday, July 27, 2010 12:29 PM

Answers

  • Hi.

    Basically you just need to put your packaged .zip file for the template into a subdirectory under the VSIX package that reflects the additional directory structure you want.

    How are you packaging the VSIX file?

    Friday, July 30, 2010 8:22 PM

All replies

  • You'll need to edit the project file directly, unfortunately (I'm assuming you're using the VSIX project type to package the template).

    Just add a metadata item called "OutputSubPath" to the VSTemplate item.

    Tuesday, July 27, 2010 1:00 PM
  • Thanks for the reply.  Unfortunately, I'm still not exactly sure where to put the element (i.e. I couldn't get it to work :-).  Below is my .vstemplate file as well as the .vsixmanifest file that I am using to package the project template.  Maybe this will shed some light on what I should be doing:

    .VSTemplate (if I manually copy the ZIP file containing this template to a sub-folder called "Windows" under the "...\Visual Studio 2010\Templates\ProjectTemplates\Visual C#" folder, it works as expected):

    <VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
     <TemplateData>
      <Name>Testable Class Library</Name>
      <Description>A project for creating a C# class library with built-in unit tests.</Description>
      <RequiredFrameworkVersion>4.0</RequiredFrameworkVersion>
      <ProjectType>CSharp</ProjectType>
      <ProjectSubType></ProjectSubType>
      <NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
      <SortOrder>1000</SortOrder>
      <CreateNewFolder>true</CreateNewFolder>
      <DefaultName>TestableClassLibrary</DefaultName>
      <ProvideDefaultName>true</ProvideDefaultName>
      <LocationField>Enabled</LocationField>
      <EnableLocationBrowseButton>true</EnableLocationBrowseButton>
      <Icon>__TemplateIcon.ico</Icon>
     </TemplateData>
     <TemplateContent>
      <Project TargetFileName="TestableClassLibrary.csproj" File="TestableClassLibrary.csproj" ReplaceParameters="true">
       <Folder Name="Properties" TargetFolderName="Properties">
        <ProjectItem ReplaceParameters="true" TargetFileName="AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem>
       </Folder>
       <Folder Name="UnitTests" TargetFolderName="UnitTests">
        <ProjectItem ReplaceParameters="true" TargetFileName="UnitTest1.cs">UnitTest1.cs</ProjectItem>
       </Folder>
      </Project>
     </TemplateContent>
     <strong><OutputSubPath>Windows</OutputSubPath>
    </strong></VSTemplate>
    

    .VSIXManifest (I want to package the above ZIP file into a VSIX file to simplify installation):

    <?xml version="1.0" encoding="utf-8"?>
    <Vsix Version="1.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2010">
     <Identifier Id="TestableClassLibraryVSIX.My Company.55f7faac-7cf8-47fb-9446-0b881808e7ef">
      <Name>Testable Class Library</Name>
      <Author>Jeff Bramwell</Author>
      <Version>1.0</Version>
      <Description xml:space="preserve">A project for creating a C# class library with built-in unit tests.</Description>
      <Locale>1033</Locale>
      <SupportedProducts>
       <VisualStudio Version="10.0">
        <Edition>Pro</Edition>
       </VisualStudio>
      </SupportedProducts>
      <SupportedFrameworkRuntimeEdition MinVersion="4.0" MaxVersion="4.0" />
     </Identifier>
     <References>
     <!--Add References here--> 
     </References>
     <Content>
      <!--Add Content here-->
      <ProjectTemplate>ProjectTemplates\TestableClassLibrary.zip</ProjectTemplate>
     </Content>
    </Vsix>
    


    I appreciate the help.


    --- Thanks, Jeff (http://devmatter.blogspot.com/)
    Tuesday, July 27, 2010 2:39 PM
  • Hi Jeff,

    As 'captain random' suggested, you need to add OutputSubPath to the VSTemplate element in your csproj/vbproj file. I also had mentioned this in a post on the Visual Studio blog a few months back. Take a look at "step 2" in the walkthrough which is what you'll need to do.

    Hope that helps,

    Aaron


    http://blogs.msdn.com/aaronmar
    Tuesday, July 27, 2010 4:44 PM
    Moderator
  • Thanks Aaron and "Capt. Random"... I was not using the VSIX Project Template but rather I was manually packaging the VSIX file.  I can go back and retrofit my template so that it is contained within a VSIX Project but I'd also really like to know how to modify the VSIX package manually so that I can accomplish the same thing.  Is this possible?


    --- Thanks, Jeff (http://devmatter.blogspot.com/)
    Wednesday, July 28, 2010 12:29 PM
  • Hi.

    Basically you just need to put your packaged .zip file for the template into a subdirectory under the VSIX package that reflects the additional directory structure you want.

    How are you packaging the VSIX file?

    Friday, July 30, 2010 8:22 PM
  • I am now making use of the VSIX Project template and finally figured out how to get it under the correct folder.  Here is what I did...

    In the VSIX project:

    1. Under the ProjectTemplates folder (that was created for me in the project), created a folder hierarchy of ProjectTemplates\CSharp\Windows
    2. Moved the project template ZIP file to the "Windows" folder
    3. Added the ZIP file to the source.extension.vsixmanifest file.

    I then built and installed the resulting VSIX and it showed up under the Visual C# folder as well as the Windows folders.

    Thanks to everyone for your help!


    --- Thanks, Jeff (http://devmatter.blogspot.com/)
    Monday, August 2, 2010 8:25 PM
  • It's exactly what I want!!
    Tuesday, July 5, 2011 7:27 AM