Tuesday, February 13, 2007

Extend right-click menu in Explorer in WiX installer

I just had the need to make an installer that created a right-click menu item for Visual Studio solution files (.sln)

The easiest way to accomplish this would have been to use the WiX built in support for registering extensions:

<Extension ContentType="text\plain" Id="sln">
<Verb Id="Visualize" Command="Visualize dependencies"
TargetFile
="DependencyVisualizerExe"
Argument
='"%1"'/>
</Extension>


However, I soon found out that this was a Bad Idea, in the sense that then my software took over as the default handler for .sln files. Not exactly what I wanted...


Turns out that I needed to manually install the registry keys/values in the appropriate place to get it to work:



<Component Id="DependencyVisualizerComponent" Guid="PUT-GUID-HERE">
<File Name="DependencyVisualizer.exe" Id="DependencyVisualizerExe"
Source
="!(wix.SourceDir)DependencyVisualizer.exe"/>
<RegistryKey Action="createAndRemoveOnUninstall" Root="HKCR"
Key
="VisualStudio.Launcher.sln\Shell\Visualize">
<RegistryValue Action="write" Value="Visualize Dependencies" Type="string" />
<RegistryKey Action="createAndRemoveOnUninstall" Key="Command">
<RegistryValue Action="write" Type="string"
Value
="&quot;[#DependencyVisualizerExe]&quot; "%1""/>
</RegistryKey>
</RegistryKey>
</Component>


Oh, and the tool I'm working on is a tool for visualizing inter-project dependencies...

No comments: