A tip that not a lot of people know is that the samples are not reset during every new release of CodeSmith. New versions of templates are added to the CodeSmith template directory for the Major and Minor versions. However that is not the case for regular builds (identified via the assembly build number) for example: 4.1.x. Please note that this will also work if you want to reset your templates for the fun of it.
You might be asking yourself, well why doesn’t CodeSmith automatically update my templates for me. Well there is a pretty good reason behind this. There is no way to know if you modified the current set of templates on your machine. If we were to just overwrite the files with the new templates that contain bug fixes, you could lose a lot of unsaved work.
So if you are experiencing a template related bug and you didn’t cleanly install CodeSmith for the very first time on your machine. The chances are your templates are out of date and need to be saved manually and updated following the steps below.
The following steps below will reset your samples to the version that of CodeSmith that you updated to, or installed to. If the samples still do not show up in CodeSmith Explorer. Then you can find the sample templates located in two zip files: samples.zip and maps.zip, located in Program Files\CodeSmith folder, and you can extract these to the correct folder inside of you’re my documents folder (Documents\CodeSmith\Samples\v4.1\Templates).
PLEASE CREATE A BACKUP OF ALL YOUR TEMPLATES BEFORE PROCEEDING!!!
First you will need to exit all CodeSmith related applications (CodeSmith Studio, Visual Studio) and follow the steps below.
- Open the Windows Run dialog box by hitting the Windows Key and R. or by going to the Start menu and clicking on run. or start -> run) dialog box and type “cmd” and click the “OK” key.
- Next type “cs /resetsamples” into the Command Prompt window and hit enter.
- Finally type “y” to confirm that you want to reset your templates and hit enter.
Congratulations your CodeSmith templates have been reset.