In this short article, the server application template created in the previous article will be turned into a real Visual Studio template. Greater minds have already described the process in the MSDN article at http://msdn.microsoft.com/en-us/library/xkh1wxd8.aspx.

Some preparation work is needed before the project can be turned into a real application template.

First, edit the AssemblyInfo.cs file, so it will look like this:

using System.Reflection; using System.Resources; using System.Runtime.InteropServices; // // General Information about the assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with the assembly. // [assembly: AssemblyTitle("$projectname$")] [assembly: AssemblyDescription("$projectname$")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("$registeredorganization$")] [assembly: AssemblyProduct("$projectname$")] [assembly: AssemblyCopyright("Copyright (c) $registeredorganization$ $year$")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] // // The version information for the assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all values, or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: NeutralResourcesLanguageAttribute("")]

In the ServerApplication.cs file, change the Application ID, Application Name and Service Name properties to:

protected override string Identifier { get { return "$guid1$"; } } protected override string ServiceName { get { return "$projectname$ Service"; } } protected override string ApplicationName { get { return "$projectname$"; } }

Open the MainService.cs in the designer and set the ServiceName property to “$projectname$ Service“.

Open the ProjectInstaller.cs in the designer and set the ServiceName property of the ServiceInstaller component to “$projectname$ Service“, as well.

Then replace the namespace ServerTemplate string with namespace $safeprojectname$ project-wide.

Save all changed files and issue the menu command File ->Export Template. Export the project as a project template. Set the template name and description and press the Finish button.

Restart Visual Studio. The template you just created will be available in the Visual Studio project templates.

P.S.: If you really don’t want to follow all those boring steps, here is the download link for the template project. Download, unzip and open it in Visual Studio, then export it as a project template.