Monday, May 27, 2013

Edit Default Visual Studio 2012 Item and Project Templates

After adding a new file or project within a Visual Studio solution there are certain settings that I always update.  Follow the steps below to edit the default templates so these settings become the default.

Visual Studio 2012 Project and Item Template files are located here:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ItemTemplates
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ProjectTemplates

Add "public" to all new C# class files:

Edit the Class.cs file by adding the word "public" in front of the word "class"

The Class.cs can be found here:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class\Class.cs

After you're done, it should look like this:

Do not add the "class1.cs" file to every new Class Library project:

Edit the "classlibrary.csproj" and "csClassLibrary.vstemplate" files found here:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ProjectTemplates\CSharp\Windows\1033\ClassLibrary\

After edited they should look like this:



Hope this helps,