title: What's wrong with my Visual Studio 2008 template?
body: <p>I'm trying to create my own class template for Visual Studio called "Public Class".</p>
  
  <p>I followed <a href="http://msdn.microsoft.com/en-us/library/ms247113.aspx" rel="nofollow noreferrer">the official MSDN instructions on how to manually create an Item Template</a> pretty much to the letter, but I'm having no luck getting the template to show up in the "My Templates" section of the "Add New Item" dialog.</p>
  
  <p>I placed PublicClass.zip in the following Windows XP directory:</p>
  
  <p>C:\Documents and Settings\My User Name\My Documents\Visual Studio 2008\Templates\ItemTemplates\Visual C#.</p>
  
  <p><strong>Public Class.zip contains the following files:</strong></p>
  
  <ol>
  <li>PublicClass.cs</li>
  <li>PublicClass.ico</li>
  <li>PublicClass.vstemplate</li>
  </ol>
  
  <p><strong>PublicClass.cs contains...</strong></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  $if$ ($targetframeworkversion$ == 3.5)using System.Linq;
  $endif$using System.Text;
  
  namespace Pse.$projectname$
  {
      public class $safeitemname$
      {
      }
  }
  </code></pre>
  
  <p><strong>PublicClass.vstemplate contains...</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;VSTemplate
    Type="Item"
    Version="1.0.0"
    xmlns="http://schemas.microsoft.com/developer/vstemplate/2005"&gt;
    &lt;TemplateData&gt;
      &lt;Name&gt;Public Class&lt;/Name&gt;
      &lt;Description&gt;An empty class declaration with access modifier = public and namespace = Pse.NameOfProject&lt;/Description&gt;
      &lt;Icon&gt;PublicClass.ico&lt;/Icon&gt;
      &lt;ProjectType&gt;CSharp&lt;/ProjectType&gt;
      &lt;DefaultName&gt;PublicClass.cs&lt;/DefaultName&gt;
    &lt;/TemplateData&gt;
    &lt;TemplateContent&gt;
      &lt;ProjectItem ReplaceParameters="true"&gt;PublicClass.cs&lt;/ProjectItem&gt;
    &lt;/TemplateContent&gt;
  &lt;/VSTemplate&gt;
  </code></pre>
  
  <p>I started up Studio, tried to add a new item to my project, but my template was nowhere to be found. So, I followed the advice of <a href="https://stackoverflow.com/questions/749979/visual-studio-2008-how-to-install-an-item-template">this stackoverflow question</a>, which was to call...</p>
  
  <pre><code>devenv.exe /installvstemplates
  </code></pre>
  
  <p>...from the command line, but all that did was make all the templates (including the built-in ones) disappear. After a few moments of panic, I eventually got them back after running the command several times, but that clearly wasn't the answer for me.</p>
  
  <p>If you see anything wrong with my procedure here, can you please help me out?</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>If I use File/Export Template (as suggested by Preet), the template <em>does</em> show up in My Templates, but the parameters are not replacing properly.</p>
  
  <p>If I insert a new "Public Class", this is what I get:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  $if$ (3.5 == 3.5)using System.Linq;
  $endif$using System.Text;
  
  namespace Pse.$projectname$
  {
      public class PublicClass1
      {
      }
  }
  </code></pre>
  
  <p>So, only <code>$projectname$</code> and <code>$targetframeworkversion$</code> are replacing properly. It's not handling the <code>$if$</code> statement or <code>$projectname$</code> properly. (I also tried using <code>$safeprojectname$</code>, but that made no difference.)</p>
  
  <p>This is definitely one of those cases where trying to make my life a little more convenient had had exactly the opposite effect :)</p>