Vista Sidebar Gadget Developer Experience

Posted Wednesday, May 02, 2007 12:58 AM by cromwellryan

Vista Sidebar Gadgets can be cool, but the developer experience out of the box is severely lacking.  Microsoft doesn't provide a Visual Studio project template, so Tim Heuer was nice enough to provide one for us.  He does so via a Web Site template, which makes sense since a Sidebar gadget is nothing more than an Html page with a splash of JavaScript, minimally, of course.  If you are like me, you like to be able to touch something up and then look at it, but I'm not about to edit, copy, run every time I want to see what my little icon change has affected.  Here's a tip to help you out: create a symbolic link in your %userprofile%\AppData\Local\Microsoft\Windows Sidebar\Gadgets directory.  Here's how:

    1. Run Command Prompt as an Administrator
    2. mklink /D "%userprofile%\AppData\Local\Microsoft\Windows Sidebar\Gadgets\<gadgetname>.gadget" "%userprofile%\Documents\Visual Studio 2005\WebSites\<VisualStudioProjectDirectory>"

This allows you to keep your projects where they belong (VS won't let you open a folder in AppData without jumping some hoops anyway) and still reload your Gadget in Sidebar whenever you make changes.

Filed under:

Comments

# re: Vista Sidebar Gadget Developer Experience

Friday, November 23, 2007 4:02 AM by Christian Jacob

Hi Ryan, great hint. Thank you. However, I wanted to add this as an "external tool" to the Visual Studio menu. Since the mklink executable must be started as admin, I an into problems there. I tried the runas.exe as command and the /user:Administrator mklink-stuff as parameter. However, there are a couple of problems. 1. Since this command will be run as admin, it's not possible to redirect to %userprofile% since this will result in a symlink not in the users profile, but in the admins profile. 2. The only internal parameter for the gadgetname that made sense to me was (%SolutionFileName) which however results in a GadgetName.sln instead of Gadgetname... so it would create a GadgetName.sln.gadget folder... 3. We have a quoting problem here also: /user:Administrator "mklink /D \"C:\Users\UserName\AppData\Local\Microsoft\Windows Sidebar\Gadgets\$(SolutionFileName).gadget\" \"$(SolutionDir)\"" As you can see, we need to enquote the parameters to mklink as well. For this we use \". However, for some reasons I don't understand, the command results in something like this: ... C:\Users\UserName\AppData\Local\Microsoft\Windows" Sidebar\Gadgets ... (with a quote character between Windows and Sidebar. Most probably because if the space character in between... i don't know how to get rid of this. The goal would be that when executing this external command, a command prompt opens up asking for the Administrators password and then creating the proper symlink. Are you able to get this working? Also, i don't know what can be done and cannot be done in the template itself. Maybe there is a way of (optionally) integrating this into it, so that when I create a new gadget based on this template, it lets me check something like "Create Symlink" and then while creating the project asking me for the admin password fr creating the symlink. What do you think?

# re: Vista Sidebar Gadget Developer Experience

Wednesday, December 19, 2007 6:14 PM by cromwellryan

Christian,

I was able to get this working with the runas option which wouldn't work.  Here's what I did:

1. Run VS 2005/2008 as Adminstrator.  Not the user administrator, but the "Run as Administrator" right click item in Vista.  This runs it under your account still, but elevated.

2. My External Tool looks like this:

  Command: c:\windows\system32\cmd.exe

  Arguments: /k mklink /D "%userprofile%\AppData\Local\Microsoft\Windows Sidebar\Gadgets\$(SolutionFileName)gadget" $(ProjectDir)

I wish there were a better variable than $(SolutionFileName), but with a Web Site project this doesn't seem possible.  Hope that helps.

Leave a Comment

(required) 
(required) 
(optional)
(required)