2012年9月17日 星期一

Create additional registry keys with DSL Tools Setup Projects



I was trying to solve the Custom Tool property issue with .actiw files in ActiveWriter, as suggested by Bogdan Pietroiu months ago, and spent a clear hour trying to figure how to inject my own registry keys into WiX setup project of DSL Tools. I modified the .vstemplate for .actiw files to include the following:

...
<CustomParameters>
  <CustomParameter Name="$itemproperties$" Value="CustomTool" />
  <CustomParameter Name="$CustomTool$" Value="ActiveWriterCodeGenerator" />
</CustomParameters>
...

and thought that the file, when added to the project, will have Custom Tool property already set. I was appearently wrong (documentation says it should work).

Bogdan's suggestion was to have a key named after the file extension under Generators\{Language}, and I manually confirmed that it works great. So, how to automate the process of adding this reg key through the setup? WiX Toolkit documentation shows the way, so I copied Registry.wxs to have my own key registered.
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>
  <Fragment Id="CustomToolFragment">
    <FeatureRef Id="DefaultFeature">
      <ComponentRef Id="_ActiveWriterCTReg" />
    </FeatureRef>
    <DirectoryRef Id="TARGETDIR">
      <Component Id="_ActiveWriterCTReg" Guid="{some GUID}">
        <Registry Root='HKLM' Key='Software\Microsoft\VisualStudio\8.0\Generators\{164b10b9-b200-11d0-8c61-00a0c91e29d5}\.actiw' Id='{some GUID}' Type='string'Value='ActiveWriterCodeGenerator' />
        <Registry Root='HKLM' Key='Software\Microsoft\VisualStudio\8.0\Generators\{fae04ec1-301f-11d3-bf4b-00c04f79efbc}\.actiw' Id='{some GUID}' Type='string'Value='ActiveWriterCodeGenerator' />
      </Component>
    </DirectoryRef>
  </Fragment>
</Wix>

<Registry> elements define the key to be added, as you may have guessed. Anyway, although I changed the build action on the .wxs and although it seems that Candle and Light picked up the file, the installer didn't add the registry key. So? Orca to the rescue. You should check Component and Registry tables in .msi file to check if your key slipped in, and Orca shows them quite detailed. In my case, though, it shows the absence of my additions.

Long story (not so) short, it seems that I should examine Registry.tt as the first step, but didn't. To include your ComponentRef in DefaultFeature, you should have your Fragment as FragmentRef in Main.wxs . So, you should add each of your custom fragment in the list defined incustomFragmentIds in InstallerDefinitions.dslsetup as shown below:

<installerDefinitionxmlns="http://schemas.microsoft.com/VisualStudio/2005/DslTools/InstallerDefinitionModel"
  ...
  customFragmentIds="CustomToolFragment">

I hope this info helps someone.

沒有留言: