I have two problems going on here: My template refuses to come in with the option to replace variables, and over the course of trying to fix it the template now appears twice.
First problem: Replacing template variables doesn't work
I tried creating a template for a file, since I will be adding a similar file two dozen times over the course of December. The template looks like this.
namespace $rootnamespace$
{
internal class Day$dayNumber$ : DayBase<$outputType$>
{
public Day$dayNumber$() : base($dayNumber$) { }
public override int FirstProblem()
{
throw new NotImplementedException();
}
public override int SecondProblem()
{
throw new NotImplementedException();
}
}
}
However, when I try to use it from the Add New menu item, it always comes out like this.
namespace AdventOfCode2023.Problems
{
internal class Day$dayNumber$ : DayBase<$outputType$>
{
public Day$dayNumber$() : base($dayNumber$) { }
public override int FirstProblem()
{
throw new NotImplementedException();
}
public override int SecondProblem()
{
throw new NotImplementedException();
}
}
}
Unzipping the template file, I find this, which looks correct.
And the template file itself looks like this.
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
<TemplateData>
<DefaultName>AdventOfCode2023.cs</DefaultName>
<Name>Advent Of Code 2023</Name>
<Description>Advent of Code 2023 template for a day's problems.</Description>
<ProjectType>CSharp</ProjectType>
<SortOrder>10</SortOrder>
<Icon>__TemplateIcon.ico</Icon>
</TemplateData>
<TemplateContent>
<References />
<ProjectItem SubType="" TargetFileName="$fileinputname$.cs" ReplaceParameters="true">Day1.cs</ProjectItem>
</TemplateContent>
</VSTemplate>
ReplaceParameters
is there, so I can't figure out what's missing.
Second problem: Old template still in list despite being deleted
Over the course of trying to fix this, I ended up cleaning up the XML above. Specifically, I added spaces in Name
and fleshed out the Description
under TemplateData
. However, now I see the template twice in the available list, once for the old and once for the new:
I have checked both OneDrive and my VS templates folder, and so far as I can tell no duplicates exist anymore, just the one I have. Anyone know how to fix this? Maybe clear a cache or force VS to rescan for templates?