Sunday 14 October 2012

Conditionally add a registry key value using Wix

We always seem to have difficulties with WPRCTokens in MS Dynamics CRM when we are load testing, so we normally set a registry entry in the MSCRM registry part called IgnoreTokenChecks to 1, this enables us to do load testing without any issues.  

Last week I was asked to include this in the build, which I thought it was a bad idea as it only seems to be relevant for load testing. At any rate, I was overruled so here it is. (Note that I added the component disabletokenchecks to the main feature <ComponentRef Id='DisableTokenChecks'/>)
  <Property Id="DYNAMICS" >
    <RegistrySearch Id="DynamicsKey" Type="raw" Root="HKLM" Key="SOFTWARE\Microsoft\MSCRM" Name="roles" Win64="yes"/>
  </Property>
 
  <Component Id="DisableTokenChecks" Guid="B4F1008F-1CF2-4170-94A5-2466AB15E145" Win64="yes">
    <Condition>DYNAMICS</Condition>   
     <RegistryValue Id="value" Action="write" Type="integer" Value="1" Name="IgnoreTokenCheck" Root="HKLM" Key="SOFTWARE\Microsoft\MSCRM"/>     
  </Component>
A few things I had to grapple with:
  1. I was compiling in an old Windows XP machine, don't even ask why, which meant that I had to add Win64=yes to the component.
  2. The condition is there to ensure that it doesn't get installed in the web server. We have a web server that doesn't have CRM installed and an app server that does.
  3. The check in the condition is made for the roles key as this key is present in the app/web server but doesn't seem to be present in the DB server.


No comments:

Post a Comment