Visual Studio. Project Templates

Recently, I’ve started not just a bit but a lot experimenting with the code approaches, writing some test scripts and applications. The result, of course, always different, but not this will be discussed today. Gradually you begin to tire of setting standard projects. For the library project we need to delete class, created there by default, because it will be too lazy to rename. I am pleased to still redirect all output of compilations to the same folder at the root of the project from all libraries, not dawdle in the folders ..\bin\Debug \ for each component of the project, to remove *.dll. For Test projects deleting useless junk is especially actual! It would be nice to also set the attributes for the assembly and the information on it for everything.

I want if you need to create something new you will chose the project – and everything is already set! And the total output folder, and the appropriate values ​​in AssemblyInfo are prescribed, and nothing too much lying around in the project. I thought  and remembered that there is an option in the studio «Get online Templates», and if it is online it should be also offline – for my own templates. Said and done

As a result, I am very happy that I spent an hour to set up all necessary projects and now I do not digress into the process, but I am glad everything turned out fine and that we should not waste time on dumb work.

To learn how to do it in Visual Studio 2008, 2010 will be discussed further. Also it wil be discussed how to delete, and import ready-made project templates in the studio.

Visual Studio 2008

Beginning more than a banal and known to the pain everyone – open studio and create the desired design.


We will train on an empty library, because such projects often have to create. After passing through the familiar wizard of creating a project can see the standard picture of the new project.

First of all remove entirely unnecessary file of class Class1. Later, you can make some patterns with some useful files, blanks, but I cannot imagine that such a universal need to always be in the new project.

The next step is to configure the information about the current built project. To do this, open the project properties (Right click on Project> Properties) and on the first tab, we can see these information

You can set the version. Net platform, the assembly name, namespace, and desired us button «Assembly Information …». Clicking it will give rise to a new dialog box where you can specify  information which is to distinguish your MyClass of similar build of Vasya Pupkin’s. :) On this tab, there is space to entertain your self-esteem

After finishing inventing the names of your future corporations (remember here the idiom about a bad soldier), you can customize and more pressing issues. Switch to the next highest tab in the properties and get to the setup project build (the tab Build).

On this tab, I’m usually was interested where the sum compiled code. I like to collect and to see it in a folder at the root of the project. To do this, find the section of the Output and input field labeled as «Output path:». You can just write a relative path to the folder where the add-ins are ready, and you can find this folder using the button «Browse …». In this case, the studio will show the full path, but do not worry if rediscovery of this tab you will see a relative path from project file.
Field «Output path:» be filled 2 times: once for the debug build, and again to release the assembly. Switch between modes enables the drop-down list, labeled as «Configuration».
For the simplest case in this setup project can be finished and go to the export project. If you need anything else (links to other projects, special files in the project), then configure it and move on to the export template.



In the main menu, in the options to work with files find the item «Export Template …»,click and see the beginning of the Assistant to export template files / projects.



For the template, you can specify an icon on which you can quickly find out your project by adding it to solution or when creating something new. Specifies the name to avoid confusion and description to avoid any doubts in the appointment of the project.
Assistant of export patterns will tell you where to look for a pattern to transfer it to your friends and colleagues, back ups, or dissection. Next, I will tell you how you can install the template, when you reinstall the studio and other misfortunes.
Do not remove the check mark from the first option «Automatically import the template into Visual Studio» and can remove it  from the second «Display an explorer window on the output files folder».
When you click Finish, to export the template work is finished and you can contemplate the result of their labors in the dialog box «Add New Project».




By default, all templates will be visible only when the left side is selected Visual C #, how to customize the appearance of patterns in the case folders will be later in the text.

Visual Studio 2010

All the above steps  work and for the 2010 studio. But there is one more way to export project templates – as an extension of the studio, which are more flexible to configure. For more in order to implement such a trick, you must download and install the Export Template Wizard
Also in the arsenal would be useful to have VSIX Explorer, if for some reason you did not have it your in your studio. You can check this by looking at the items in the menu Tools.
Once you have set up a project for their own use, open the main menu item File and see a new option «Export Template as VSIX …».


Assistant appears in a format to create templates VSIX, strongly echoing the original places.


Choose a project to export and click on, there’s nothing interesting there.
On the next step of an assistant, we see new options and opportunities. You can set a pretty picture with a logo or a pattern to make an impression on novices or for yourself. The last two fields hint at the exciting new opportunities to create a project, but I do not understand them, to be honest. When I understand them  and come up with them a useful application, so I’ll tell you. Maybe you can make when creating a project to run the tests, it will bw possible to specify assembly references that will participate in testing.


On the next screen you see information that applies fully to a new kind of extensions to the studio:

Id expansion pack, so it could refer to other extensions

Licenses to use

Link to guidance on the use or configuration

Support for any versions of the studio include

And as you can see the part of the standard options for export assistant.



In this step you can specify that our template is compatible with all editions of the studio in 2010, for which click on the button «Select …» next to Supported VS Editions,then there is a new window, where we put a checkmark in all the items and confirmyour choice.


After all the manipulations you can press Finish, and look for your project templateinstalled in the gallery of projects!

Further improvements
After a while I got tired of having all my templates are in a heap under the main point ofVisual C # to add a project, rather than by categories: Windows, Test, DataBase, etc.Unfortunately, the standard means to move the project in no other category. But you can do it all yourself!
Take your project template and go at C: \ Program Files (x86) \ Microsoft Visual Studio 9.0 \ Common7 \ IDE \ ProjectTemplates \ CSharp find there a category, open it andget to the folder where zip archives are there and put your pattern. Restart the studio and observe the result.
If there is no result, then we must delete proet??? caches. To do this, go to the address C: \ Program Files (x86) \ MicrosoftVisual Studio 9.0 \ Common7 \ IDE \ ProjectTemplatesCache and delete the file cache.bin. After that studio again interrogates all folders, find your project and include it in the appropriate section.
For studio 2010, all the same, except that the number of studio 10.0.


Installation is very simple: you must copy the pattern or as indicated above, or in the% Documents% \ Visual Studio 2008 \ Templates \ ProjectTemplates \ Visual C # (% Documents% \ Visual Studio 2010 \ Templates \ ProjectTemplates \ Visual C #, respectively).
For studio 2010 , if you have a project template in the studio as an extension VSIX, then double click on all the self install.
As you can see any problems when installing new templates should arise.


But this is quite non-obvious point, as it turned out. In the process of experimentation, I made many templates, but here’s how to remove them … the Quick button to remove the template was not found. Yes, apparently there is no such =) Internetgenerously shared information about how to create templates, but here’s how to remove them from the collection of projects, almost anything. I had to try all of the scientific method at random

VS 2008

Removal of the 2008 studio is fairly painless and quick. Need to find the folder% Documents% \ Visual Studio 2008 \ Templates \ ProjectTemplates \ Visual C #, there is a template and simply delete it, then restart the studio. It is also desirable to kill the cache project. To do this, go to adresuC: \ Program Files (x86) \ Microsoft Visual Studio 9.0 \ Common7 \ IDE \ ProjectTemplatesCache and remove faylcache.bin.
Actually this’s al!

VS 2010

If you created a standard project template as a zip archive, you will need to repeat the same steps as for the studio  2008, as amended by the way to the studio version. If exported as vsix, then action will be somewhat different.
First you need to go at% user% \ AppData \ Local \ Microsoft \ VisualStudio \ 10.0 \ Extensions and there find its expansion. Remove it. Then we need to necessarily kill the cache design templates. This item is located at% user% \ AppData \ Local \ Microsoft \ VisualStudio \ 10.0 \ ComponentModelCache.Esli you do not push through its template in the category of pre-patterns, then it should disappear. I’ve got this for myself))

Field for further development

It is necessary to further explore the possibility of creating patterns at once decisions on several projects at once. It would be interesting to look at new opportunities vsix packages are created for them as assistants to the creation and stuff like that.
In general, I suggest you practice on this field of in handy!





Tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>