Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116958

Detecting SQL server install directory

I am trying to find the install directory for SQL server. So that I can copy the dlls for a custom SSIS task into it.

The following code runs but its not copying my files. Its not stopping either so I am assuming that it has found some value for ISSQLSERVERSERVICEINSTALLED

I am very new to wix this is the first time I have tried to read from the register.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="*" Name="Daimto OpenWeather for SSIS" Language="1033" Version="1.0.0.0" Manufacturer="DAIMTO" UpgradeCode="84543418-55c4-48c0-b5be-2496fb84ffb6">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perUser"  InstallPrivileges="elevated" AdminImage="yes" />
    <MediaTemplate EmbedCab="yes" CompressionLevel="high" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />


    <Feature Id="SSISMSSQL" Title="SSIS Components" Display='expand'  Level='1'>
      <ComponentRef Id='SSISPipelineComponents' />
      <ComponentRef Id='SSISConnections' />
    </Feature>
    <UIRef Id="WixUI_Minimal"/>
  </Product>


  <!-- Get the directory name-->
  <Fragment>
    <Property Id="SQLSERVERINSTALLFOLDER">
      <RegistrySearch Id='InstallDir'
                    Type='raw'
                    Root='HKLM'
                     Key="SOFTWARE\Microsoft\Microsoft SQL Server\100" Name="VerSpecificRootDir" />

    </Property>
    <Condition Message='Install Folder not found'>SQLSERVERINSTALLFOLDER</Condition>
  </Fragment>

  <!-- Build directory structure. http://blogs.msdn.com/b/syamp/archive/2012/09/30/wix-search-for-install-path-from-registry.aspx -->
  <Fragment>
    <Directory Id = "TARGETDIR" Name="SourceDir">
      <Directory Id="SQLSERVERINSTALLFOLDER" >
        <Directory Id="DTSDir" Name="DTS">
          <Directory Id="PIPELINECOMPONENTS" Name="PipelineComponents" />
          <Directory Id="CONECTIONS" Name="Connections" />
        </Directory>
      </Directory>
    </Directory>

    <!-- Set tarit dir to c: -->
    <SetDirectory Id="TARGETDIR" Value="[WindowsVolume]" />
  </Fragment>

  <!-- copie files. -->
  <Fragment>
    <ComponentGroup Id="SSISPipelineComponentsgrp" Directory="PIPELINECOMPONENTS">
      <Component Id="SSISPipelineComponents" Guid="{51CE96C7-42BF-4CE7-AE88-5C0085868062}" >
        <File Id="Daimto.SSIS.Tasks.Current" Name="Daimto.SSIS.Tasks.Current.dll" DiskId="1" KeyPath="yes" Source="$(var.Daimto.SSIS.Tasks.Current.TargetPath)" />
      </Component>
    </ComponentGroup>
    <ComponentGroup Id="SSISConnectionsgrp" Directory="CONECTIONS">
      <Component Id="SSISConnections" Guid="{8DFFB861-18E4-4E08-8D4E-CAD99911E8A8}" >
        <File Id="Daimto.SSIS.Connection" Name="Daimto.SSIS.Connection.dll" DiskId="1" KeyPath="yes" Source="$(var.Daimto.SSIS.Connection.TargetPath)" />
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>

Update 1:

enter image description here

Update 2:

I am getting some where. Its now installing on my Ddrive....

MSI (c) (CC:98) [13:37:09:112]: PROPERTY CHANGE: Adding TARGETDIR property. Its value is 'D:\'.
MSI (c) (CC:98) [13:37:09:112]: PROPERTY CHANGE: Adding ISSQLSERVERSERVICEINSTALLED property. Its value is 'D:\'.
MSI (c) (CC:98) [13:37:09:112]: PROPERTY CHANGE: Adding DTS property. Its value is 'D:\DTS\'.
MSI (c) (CC:98) [13:37:09:113]: PROPERTY CHANGE: Adding CONECTIONS property. Its value is 'D:\DTS\Connections\'.
MSI (c) (CC:98) [13:37:09:113]: PROPERTY CHANGE: Adding PIPELINECOMPONENTS property. Its value is 'D:\DTS\PipelineComponents\'.

Which leads me to believe that its not finding ISSQLSERVERSERVICEINSTALLED.

update 3:

Its now installing on the c drive. but its creating a directory called SQLSERVERINSTALLFOLDER, its not taking a value. log file says that the value of SQLSERVERINSTALLFOLDER is c: I cant figure out if its even able to find the registry value or not. I tried adding a condition to force it to fail but its not failing

<Condition Message='Install Folder not found'>SQLSERVERINSTALLFOLDER</Condition>

Upvotes: 2

Views: 545

Answers (1)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116958

I finally got it working, the problem was that the fragment wasint being called I had to add <ComponentGroup Id="Fake" /> to the fragment then declare it with the other componentRefs.

The following code detects sqlserver 2008 copyes the connection manager and the data reader to the correct dts folders and installs them both in GAC after.

Hope this helps someone.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="*" Name="Daimto for SSIS (SQL Server 2008)" Language="1033" Version="1.0.0.0" Manufacturer="DAIMTO" UpgradeCode="84543418-55c4-48c0-b5be-2496fb84ffb6">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perUser"  InstallPrivileges="elevated" AdminImage="yes" />
    <MediaTemplate EmbedCab="yes" CompressionLevel="high" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

    <Feature Id="SSISMSSQL" Title="SSIS Components" Display='expand'  Level='1'>
      <ComponentRef Id='SSISPipelineComponents' />
      <ComponentRef Id='SSISConnections' />
      <ComponentGroupRef Id="CopyGAC"/>
      <ComponentGroupRef Id="Fake"/>
    </Feature>
    <UIRef Id="WixUI_Minimal"/>
  </Product>


  <!-- Get install location of SQL Server 2008 -->
  <Fragment>
    <Property Id="SQLSERVERINSTALLFOLDER">
      <RegistrySearch Id='InstallDir'
                    Type='directory'
                    Root='HKLM'
                     Key="SOFTWARE\Microsoft\Microsoft SQL Server\100" Name="VerSpecificRootDir" />

    </Property>
    <Condition Message='Install Folder not found'>SQLSERVERINSTALLFOLDER</Condition>
    <ComponentGroup Id="Fake" />
  </Fragment>

  <!-- map the directory structures -->
  <Fragment>
    <Directory Id = "TARGETDIR" Name="SourceDir">
      <Directory Id="GAC" Name="GAC" />
      <Directory Id="SQLSERVERINSTALLFOLDER" >
        <Directory Id="DTSDir" Name="DTS">
          <Directory Id="PIPELINECOMPONENTS" Name="PipelineComponents" />
          <Directory Id="CONECTIONS" Name="Connections" />
        </Directory>
      </Directory>
    </Directory>

    <!-- Set TARGETDIR dir to c: -->
    <SetDirectory Id="TARGETDIR" Value="[WindowsVolume]" />
  </Fragment>

  <!-- copie files. -->
  <Fragment>

    <!-- copy data reader files -->
    <ComponentGroup Id="SSISPipelineComponentsgrp" Directory="PIPELINECOMPONENTS">
      <Component Id="SSISPipelineComponents" Guid="{51CE96C7-42BF-4CE7-AE88-5C0085868062}" >
        <File Id="Daimto.SSIS.Tasks.Current" Name="Daimto.SSIS.Tasks.Current.dll" DiskId="1" KeyPath="yes" Source="$(var.Daimto.SSIS.Tasks.Current.TargetPath)" />
        <File Id="Newtonsoft.Json.dll" Name="Newtonsoft.Json.dll" DiskId="1" KeyPath="no" Source="$(var.ProjectDir)Externals\Newtonsoft.Json.dll" />
      </Component>
    </ComponentGroup>

    <!-- copy connection manager file -->
    <ComponentGroup Id="SSISConnectionsgrp" Directory="CONECTIONS">
      <Component Id="SSISConnections" Guid="{8DFFB861-18E4-4E08-8D4E-CAD99911E8A8}" >
        <File Id="Daimto.SSIS.Connection" Name="Daimto.SSIS.Connection.dll" DiskId="1" KeyPath="yes" Source="$(var.Daimto.SSIS.Connection.TargetPath)" />
      </Component>
    </ComponentGroup>

    <!-- copy everything to GAC (remember dlls must be strong name signed.) -->
    <ComponentGroup Id="CopyGAC" Directory="GAC">
      <Component Id="GACCOPYCurrent" Guid="{4D4E991E-77F5-4CCF-9048-B4C0260B43BD}" >
        <File Id="GACDaimto.SSIS.Tasks.Current" Name="Daimto.SSIS.Tasks.Current.dll"  KeyPath="yes" Source="$(var.Daimto.SSIS.Tasks.Current.TargetPath)" Assembly=".net"/>
      </Component>
      <Component Id="GACCOPYJson" Guid="{65E88F62-E73F-4851-9422-6C8D1DA5183F}" >
        <File Id="GACNewtonsoft.Json.dll" Name="Newtonsoft.Json.dll"  KeyPath="yes" Source="$(var.ProjectDir)Externals\Newtonsoft.Json.dll" Assembly=".net"/>
      </Component>
      <Component Id="GACCOPYConnection" Guid="{2DCABCEA-62CD-4F0D-BCAC-395A079AF27A}" >
        <File Id="GACDaimto.SSIS.Connection" Name="Daimto.SSIS.Connection.dll" KeyPath="yes" Source="$(var.Daimto.SSIS.Connection.TargetPath)" Assembly=".net"/>
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>

Upvotes: 2

Related Questions