Installing an MSBuild extension

installationmsbuildwix

I have created a task for MSBuild that is to be used by developers and would like to create an installer to install the task and the associated .targets file into the MSBuild extensions folder in Program Files (usually C:/Program Files/MSBuild on 32-bit XP).

To do this properly, I would like to ask the system for that folder location at installation time – is there a registry key that provides this information or some other installer property? I intend to use WiX for the installation.

Best Answer

Wix itself has a MSBuild task so I think its best to see how they did it, the relvent source is Toolset.wxs (Google Code Search).

Look at the part where they defined the MSBuild Folder:

<DirectoryRef Id="ProgramFilesFolder">
    <Directory Id="Dir_MSBuild" Name="MSBuild">
        <Directory Id="Dir_MSBuildMS" Name="Microsoft">
            <Directory Id="Dir_MSBuildMSWix" Name="WiX">
                <Directory Id="Dir_MSBuildMSWix35" Name="v3.5">
                    <Component Id="WixMSBuildBinaries35" 
                              Guid="2CB1EA5F-2542-4AFF-A05B-FAF576265F89" 
                              Win64="no">
                        <File Source="WixTasks.dll" Checksum="yes" 
                              KeyPath="yes" Vital="yes" />
                    </Component>
                </Directory>
            </Directory>
        </Directory>
    </Directory>
</DirectoryRef>

This will install the Wix MsBuild task (WixTasks.dll) under \Program Files\MSBuild\Microsoft\Wix