This is the first part in a series of tutorials aimed at guiding novice developers though building a "Hello World" Windows Home Server Add-In, using only freely-available tools (including Visual Studio Express).

One of the major barriers for beginning developers creating Add-Ins is that the initial setup and configuration of the development environment is fairly convoluted; you need to bring together quite a few components to even make a start. Because of this, Part 1 of our tutorial guides you through the installation and configuration of Visual Studio Express, with some Windows Home Server-specific steps.

It's not glamorous, but it needs to be done!

I'm going to assume you're working with Windows XP, but Windows Vista setup should be basically identical to the steps outlined below.

For this tutorial, we're building a Windows Home Server Add-In that detects changes to Shared Folder permissions. You can access the other parts of the tutorial, or download the code I'm using in the screenshots, using the links below.

  • Part 1: Installing and configuring your development environment
  • Part 2: Designing a GUI and initial deployment test
  • Part 3: Responding to Windows Home Server Notifications (code)
  • Part 4: Using FancyListView and comparing permissions (code)
  • Part 5: Building an installer package using WiX (code)

 

Step 1: Downloading and Installing Visual Studio Express

Jump over to http://www.microsoft.com/express/download/ and download Visual Studio Express for C#. You want the Web Install, so just click Download.

001-Download-VS-Express 002-Install-VS-Express

The installer will pull down all of the various packages you need, install them, and then prompt you to restart your computer. Once you've restarted, Visual Studio will finish up the installation.

003-Install-VS-Express 004-Install-VS-Express

005-Install-VS-Express 006-Install-VS-Express

 

Step 2: Running Visual Studio Express for the first time

Visual Studio Express will spend some time setting up your initial environment. Once loaded, you'll want to register the software so it doesn't expire on you in 30 days. From the Help menu, select Register Product.

007-Run-VS-Express  009-Run-VS-Express

Click the Register Now link, sign in with a Windows Live ID, and complete the registration form.

010-Run-VS-Express 011-Run-VS-Express

Copy the registration code into Visual Studio and click Complete Registration.

012-Run-VS-Express 013-Run-VS-Express

 

Step 3: Download and Install WiX

WiX is a great framework for building MSI packages. You'll need to package your code as an MSI, and customize some settings, in order for Windows Home Server to see it as a valid Add-In to install.

Browse to http://wix.sourceforge.net/ and hit the Weekly Releases section (http://wix.sourceforge.net/releases/).

WiX 3.0 is alpha code, but it's the best option for us at the moment. I've been using WiX 3.0 weekly releases to build my production installers for WHS Disk Management from the start, and it's been rock solid for me.

Navigate to the latest build number, download Wix3.msi and install it.

015-Download-Wix

WiX will complain that you're using Visual Studio Express, but that's expected. WiX won't allow us to use the fancy GUI tools to build packages in Visual Studio Express, but we'll still get command line options. And everyone loves the command line.

016-Download-Wix 017-Download-Wix

 

Step 4: Referencing the Windows Home Server libraries

In order to write code that references Windows Home Server, we need access to the WHS libraries. These will be referenced by Visual Studio, and will allow us to use all the cool WHS GUI bits.

We'll grab these files off our server.

Click Start, Run, type mstsc -console, and then click OK. Enter the name of your server, click the Options button, navigate to the Local Resources tab and then click More. Check the box next to Drives, then click OK.

We're doing this so we can copy and paste files back and forth between our development machine and our server.

018-Connect-to-WHS 018a-Change-RD-settings

Click Connect, and then enter your server's Administrator username and password.

019-Connect-to-WHS  020-Connect-to-WHS

Navigate to C:\Program Files\Windows Home Server\. You now want to select all the Application Extension files; the easiest way to do this is to sort by Type.

I've left off the Xceed libraries here; they're what the console uses to display various charts and graphs, and we don't have a license to use those libraries.

Copy the files (CTRL-C), minimize the Remote Desktop session, and then paste the files (CTRL-V) into a folder on your computer. I've stuck the files in a subfolder of the My Documents\Visual Studio 2008\ folder, but you can put them anywhere.

 021-Save-assemblies 022-Save-assemblies

Brendan Grant has blogged this part of the tutorial already, but I'm including it here for completeness.

Once you've copied the Windows Home Server libraries to your local machine, we need to add a registry entry to tell Visual Studio where to find them. When you add references in Visual Studio, you can manually navigate to the appropriate library, but that gets old fast. This way is easier.

Open regedit and navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx. Right-click AssemblyFoldersEx and create a new Key.

023-Reference-assemblies 024-Reference-assemblies

Call the new key Windows Home Server. Modify the Default entry for your new key, and enter the path to the library files we copied earlier. Click OK to save the path, and then close regedit.

025-Reference-assemblies 026-Reference-assemblies

 027-Reference-assemblies 028-Reference-assemblies

 

Step 5: Adding Windows Home Server controls to the Visual Studio Toolbox

Building Windows Forms applications is always easier when you can use the Visual Studio Designer to drag and drop controls and components. We'll add the Windows Home Server controls to a new Toolbox tab so we can drop them into our Add-In as needed.

Open Visual Studio, and display the Toolbox using the View menu. Right-click the Toolbox, and choose Add Tab.

029-Toolbox-controls 030-Toolbox-controls

Name your new tab Windows Home Server, then right-click the tab and select Choose Items.

031-Toolbox-controls 032-Toolbox-controls

You'll be presented with a window from which you can select various controls. Click the Browse button and navigate to the folder where you saved the Windows Home Server libraries. Select homeservercontrols.dll and click Open.

033-Toolbox-controls 034-Toolbox-controls

Don't touch anything!

All the Windows Home Server controls loaded from homeservercontrols.dll are highlighted, and you don't want to manually go back through that list clicking them all. Just press the space bar once, and they'll all be checked, then click OK.

035-Toolbox-controls 036-Toolbox-controls

 

Step 6: Installing Brendan's Add-In Templates

This is the last step for this part of the tutorial.

Download Brendan's C# templates (http://ihatelinux.blogspot.com/2007/11/whs-developer-tip-4-project-templates.html) and save the zip file to My Documents\Visual Studio 2008\Templates\Project Templates\Visual C#\.

037-Save-templates 

Now reopen Visual Studio and choose File --> New --> Project. You'll see Home Server Add-In as an available template.

039-Open-templates

Your development environment is now ready to begin work on an Add-In. Next time, we'll create a new Add-In from Brendan's template and actually display something in the Windows Home Server Console.

(If you can't wait until then, and decide to go diving in without me, make sure to retarget the project to .NET 2.0; Visual Studio 2008 defaults to .NET 3.5, which isn't installed by default on Windows Home Server.)

Edit: Thanks to Chris and Kevin for pointing out that you just need to save the zip file to the templates folder; extracting the contents of the zip won't work.

posted on Friday, December 05, 2008 6:41 PM | Filed Under [ Windows Home Server Development ]

Comments

Gravatar
# re: "Hello World" Windows Home Server Add-In: Part 1 (Tayyab @ 3/2/2010 12:26 PM)

Thanks for having us such a detailed tutorial. Every thing went well for me until Step # 6. I saved the rendan's C# templates in My Documents\Visual Studio 2008\Templates\Project Templates\Visual C#\ .. then reopened the Visual Studio BUT ... couldn't find Home Server add-In icon yet. What could have gone wrong?

I have checked all my steps thoroughly but still no hope. Please reply!

Thanks
 
Gravatar
# re: "Hello World" Windows Home Server Add-In: Part 1 (Tayyab @ 3/2/2010 12:50 PM)

Strange things happen when you get panic :)

I got my problem solved after File->New->Project and selecting Visual C#, I was able to see the Home Server Add-In icon. Instead i was trying to find the icon in Visual C# -> Windows

and also I was extracting the template files which is wrong and we should just copy the Home Server add-In templates zip file to Visual Studio 2008\Templates\ProjectTemplates\Visual C# directory

Thanks for your article!

 
Gravatar
# re: "Hello World" Windows Home Server Add-In: Part 1 (noor @ 5/13/2010 3:51 AM)

i like this .

Post Comment

Title *
Name *
Email
Url
Comment *  
Remember me
Please add 7 and 5 and type the answer here:

Search

Site Sections

Recent Posts

Archives

Post Categories

WHS Add-In Tutorial

WHS Blogs

WHS Development