I’d like to build an MSI installer that installs a managed DLL and makes it accessible to users from Visual Studio’s “Add References” menu in Solution Explorer. I believe I am supposed to add a key into the Windows registry but I cannot see how to tell the VS project for the MSI to do this at install.
How is this done and where should I look for tutorials on this kind of thing?
Go to the following registry key:
Add a subkey (the name of which doesn’t matter, but might as well be descriptive) whose default value is the folder containing your assemblies, and you should be good to go.
How to add the required key using WiX
This is a stripped-down fragment of WiX code for creating the required key and setting its default value to the folder in which your assemblies were installed. This is not a complete WiX installer and cannot be pasted directly — I have removed Guid attributes and shown only the Directory, Component and Feature declarations. Once you’ve seen some complete WiX code it should be reasonably clear how to merge these bits in.
To build the MSI once you’ve got a full WiX script, you can use a batch file, the core of which looks like this:
where %WXS_NAME% is the name of the WiX .wxs source file.
(I realise this probably looks a bit cryptic but (a) there are lots of WiX samples, tutorials and reference material out there to help you get started and (b) the Votive add-in for Visual Studio may shield you from some of the guts anyway.)
To automatically build the MSI, use the Votive add-in (part of WiX), or a post-build step, or a MSBuild build script. We use a build script because we usually want to build the MSI only as part of our automated build — doing it in a post-build step would slow down development builds — but your mileage may vary.