.comment-link {margin-left:.6em;}

I Hate Linux

Monday, November 12, 2007

WHS Developer Tip #4: Project Templates

Q: Is there an easier way to get started in building my add-in other than building it from scratch... like a project template?

A: There are no official project templates and to fill this gap back in April (now) WHS MVP Ken Warren did release a couple example templates that I've used for every single add-in and test add-in I've written.

Unfortunately as useful as his templates are, they have a number of issues that require some extra work to make work property, so I built a couple of new and improved ones:

Looking for another language? Managed C++? J#? Feel free to ask.

Installation Instructions

Copy the language template of your choice to the following directory on your Vista development machine:

Edit: After much feedback it must be said that users of these templates SHOULD NOT extract the zip contents to the following locations, instead they should SAVE the file there. Visual Studio expects a zip, not a directory or files.

%UserProfile%\Documents\Visual Studio 2005\Templates\ProjectTemplates\<Language>\

or under XP/2003:

%UserProfile%\My Documents\Visual Studio 2005\Templates\ProjectTemplates\<Language>\

Where <Language> is either Visual C# or Visual Basic.

Usage

Launch Visual Studio 2005**, bring up the New Project dialog and select the language of your choice. Under the My Templates section you will see a template named Home Server Add-In (apologies for the poor icons*), select it, type in a name for your project and press the OK button.

The created project will contain 2 different kinds of files, user controls and the required Home Server classes.

Two classes named HomeServerTabExtender and HomeServerSettingsExtender do the work of informing the Home Server Console what controls exist in your add-in, what their display name should be and other settings. With the exception of changing the display text and icon, you can largely leave these classes alone.

There are also two user controls named MainTabUserControl and SettingsTabUserControl which are the place for you to add your custom layout and code with the ease of the Visual Studio Forms Designer.

There are just two things that you'll need to do before your new add-in will be useable on your Home Server...

Add Reference

Unless you've specially rigged your development environment (which I'll cover in a later Dev Tip), you'll need to manually add a reference to HomeServerExt.dll (located in C:\Program Files\Windows Home Server\ on your Home Server).

Visual Studio Bug

For your add-in to be detected by the Home Server Console, the deployed assembly must have a name and namespace that match the following pattern:

Assembly Name:
HomeServerConsoleTab.YourTabName

Namespace:
Microsoft.HomeServer.HomeServerConsoleTab.YourTabName

Where YourTabName is the unique name you've given to your tab.

In order to make your tab meet these requirements, you will need to edit your project's properties and change the assembly name to meet the above criteria.

As easy as it is to make an add-in with these templates, a bug exists in Visual Studio 2005 and 2008 which allows the dynamic naming of the namespace based on the project name you specify... however the assembly name is always set to the project name, something that isn't always desired.

Deployment

To use your new add-in, simply copy it to the C:\Program Files\Windows Home Server\ directory on your Home Server and re-start the Home Server Console.

You can also make your own installer using WiX or Visual Studio Setup Project to install your add-in through the Home Server Console.

*If any readers have any suggestions as to how these templates could be improved, or want to make a better looking icon for the templates, please let me know.

**These templates have also been tested with the the beta 2 version of Visual Studio 2008 and to make them visible, change the directories mentioned previously appropriately (2005 -> 2008).

Note: The information in this post is based on undocumented and at times deduced information on Windows Home Server and is not officially supported or endorsed by Microsoft and could very easily be wrong or subject to change in future, so please take it and everything else said on this blog with a grain of salt and use with caution.

Labels:

11 Comments:

  • Thanks for making these! You rock!

    By Blogger Robert Stinnett, at 8:19 PM  

  • I'm glad you like them

    By Blogger Brendan, at 1:44 PM  

  • I'm unable to get the VB template to be seen by VS 2005. I unzipped the file and dropped the contents into the appropriate folder (which for me is \\server\Users\Jody\My Documents\Visual Studio 2005\Templates\ProjectTemplates\Visual Basic. Any ideas?

    By Blogger JammerX19, at 4:52 PM  

  • You don't need to unzip them... just drop the zip file itself in that folder and launch Visual Studio.

    Note that you will need to select the Visual Basic language in order to see the template be displayed, not one of the sub project types (Windows, Smart Device, Web, etc)

    By Blogger Brendan, at 6:29 AM  

  • I did the same thing. Dont unzip the file and it will pick up the template with 2008 as well.

    By Anonymous Anonymous, at 12:40 PM  

  • Hey Brendan, Is it too late to request a C++ template? I know you're working for MS now but I would really appreciate you taking time to do this.

    ...TxDot

    By Blogger David, at 9:24 PM  

  • Excellent!!

    Just created a simple SysLogViewer/Deamon tab that displays my router messages if the Console is running.

    The WHS part was really simple (getting the syslog running and parsing it's output was much harder).

    By Blogger Wim, at 9:22 AM  

  • Hi,

    Got a question or two!

    1) How do I get a reference to the Tab from within the Setup? I would like to configure the Tab's internals or do I have to do it through registry settings etc.

    2) How do I respond to Apply and OK buttons in the Setup? Could you add some events for this?

    By Blogger wvd_vegt, at 9:40 AM  

  • Last question today,

    How do i get the nice buttonbar on top. I tried a MenuStrip but that turns out rather grey (an un-WHS-like).

    By Blogger wvd_vegt, at 9:51 AM  

  • Hi Brendan,

    Already found the rest of your excellent work on WHS Add-ins. Keep on digging!!!

    By Blogger wvd_vegt, at 11:28 AM  

  • Thanks for making it so clear and exceptional guidance.

    By Anonymous PSD To Wordpress, at 12:30 AM  

Post a Comment

<< Home