0

Hello I am really new to WiX. I have a application that i need to Also install the drivers (.inf, .cat, .sys) for along with desktop icons start menu shortcuts and so forth. I have tried implementing the different codes That have to do with such from SO but am not having much luck I have also tried KK's blog and tried following his example. Still no luck i can get the desktop Icons and start menu icons to install but need to also install the drivers for this application when it installs the rest. Does anybody have a straight all the way threw example i could follow to do so.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" 
     xmlns:difx="http://schemas.microsoft.com/wix/DifxAppExtension">

<?define CyUSB_TargetDir=$(var.CyUSB.TargetDir)?>
<?define RAMware3_TargetDir=$(var.RAMware3.TargetDir)?>

<Product Id="*" Name="RamWare3" Language="1033" Version="1.0.0.0" Manufacturer="Resodyn Acoustic Mixers" UpgradeCode="*">

   <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

   <Icon Id="rw3.ico" SourceFile="$(var.ProjectDir)License\rw3.ico" />
   <Property Id="ARPPRODUCTICON" Value="rw3.ico" />

   <WixVariable Id="WixUIBannerBmp" Value="License\installer_top-banner.bmp" />
   <WixVariable Id="WixUIDialogBmp" Value="License\installer_background.bmp" />
   <WixVariable Id="WixUILicenseRtf" Value="$(var.ProjectDir)License\License.rtf" />

   <Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
   <UIRef Id="WixUI_InstallDir" />

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

   <Feature Id="ProductFeature" Title="RamWare3" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
      <ComponentRef Id="ApplicationShortcut" />
      <ComponentRef Id="ApplicationShortcutDesktop" />
      <ComponentGroupRef Id="ProgramFilesFolder_files" />
      <ComponentGroupRef Id="ApplicationProgramsFolder_files" />
   </Feature>

   <Feature Id="MyDrivers" Title="My Drivers">
      <Component Id="Drivers" Directory="DriverDir" Guid="*">
         <File Id="reusb.inf" Source="$(var.ProjectDir)\Drivers\reusb.inf" />
         <File Id="reusb.sys" Source="$(var.ProjectDir)\Drivers\reusb.sys" KeyPath="yes" />
         <File Id="WdfCoinstaller01011.dll" Source="$(var.ProjectDir)\Drivers\WdfCoinstaller01011.dll" />
         <difx:Driver AddRemovePrograms="no" Legacy="no" PlugAndPlayPrompt="no" Sequence="1" />
      </Component>
   </Feature>
</Product>

<Fragment>
   <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
         <Directory Id="INSTALLFOLDER" Name="RamWare3">
         </Directory>
      </Directory>
      <Directory Id="ProgramMenuFolder">
         <Directory Id="ApplicationProgramsFolder" Name="Resodyn Acoustic Mixers"/>
      </Directory>
      <Directory Id="DesktopFolder" Name="Desktop" />
   </Directory>
</Fragment>

<Fragment>
   <DirectoryRef Id="ApplicationProgramsFolder">
      <Component Id="ApplicationShortcut" Guid="*">
         <Shortcut Id="ApplicationStartMenuShortcut" Name="RamWare3" Description="RamWare3" Target="[INSTALLFOLDER]RamWare3.exe" WorkingDirectory="INSTALLFOLDER" />
         <RemoveFolder Id="RemoveApplicationProgramsFolder" Directory="ApplicationProgramsFolder" On="uninstall" />
         <RegistryValue Root="HKCU" Key="Software\RamWare3" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
   </DirectoryRef>
   <DirectoryRef Id="DesktopFolder">
      <Component Id="ApplicationShortcutDesktop" Guid="*">
         <Shortcut Id="ApplicationDesktopShortcut" Name="RamWare3" Description="RamWare3" Target="[INSTALLFOLDER]RamWare3.exe" WorkingDirectory="INSTALLFOLDER" />
         <RemoveFolder Id="RemoveDesktopFolder" Directory="DesktopFolder" On="uninstall" />
         <RegistryValue Root="HKCU" Key="Software\RamWare3" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
   </DirectoryRef>
</Fragment>

<Fragment>
   <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
      <Component Id="CyUSB.dll" Guid="*">
         <File Id="CyUSB.dll" Name="CyUSB.dll" Source="$(var.CyUSB_TargetDir)CyUSB.dll" />
      </Component>
      <Component Id="RAMware3.exe" Guid="*">
         <File Id="RAMware3.exe" Name="RAMware3.exe" Source="$(var.RAMware3_TargetDir)RAMware3.exe" />
      </Component>
      <Component Id="RAMware3.exe.config" Guid="*">
         <File Id="RAMware3.exe.config" Name="RAMware3.exe.config" Source="$(var.RAMware3_TargetDir)RAMware3.exe.config" />
      </Component>
      <Component Id="Microsoft.Practices.ServiceLocation.dll" Guid="*">
         <File Id="Microsoft.Practices.ServiceLocation.dll" Name="Microsoft.Practices.ServiceLocation.dll" Source="$(var.RAMware3_TargetDir)Microsoft.Practices.ServiceLocation.dll" />
      </Component>
      <Component Id="Nito.AsyncEx.Concurrent.dll" Guid="*">
         <File Id="Nito.AsyncEx.Concurrent.dll" Name="Nito.AsyncEx.Concurrent.dll" Source="$(var.RAMware3_TargetDir)Nito.AsyncEx.Concurrent.dll" />
      </Component>
      <Component Id="Nito.AsyncEx.dll" Guid="*">
         <File Id="Nito.AsyncEx.dll" Name="Nito.AsyncEx.dll" Source="$(var.RAMware3_TargetDir)Nito.AsyncEx.dll" />
      </Component>
      <Component Id="Nito.AsyncEx.Enlightenment.dll" Guid="*">
         <File Id="Nito.AsyncEx.Enlightenment.dll" Name="Nito.AsyncEx.Enlightenment.dll" Source="$(var.RAMware3_TargetDir)Nito.AsyncEx.Enlightenment.dll" />
      </Component>
      <Component Id="Microsoft.Threading.Tasks.Extensions.Desktop.dll" Guid="*">
         <File Id="Microsoft.Threading.Tasks.Extensions.Desktop.dll" Name="Microsoft.Threading.Tasks.Extensions.Desktop.dll" Source="$(var.RAMware3_TargetDir)Microsoft.Threading.Tasks.Extensions.Desktop.dll" />
      </Component>
      <Component Id="Microsoft.Threading.Tasks.Extensions.dll" Guid="*">
         <File Id="Microsoft.Threading.Tasks.Extensions.dll" Name="Microsoft.Threading.Tasks.Extensions.dll" Source="$(var.RAMware3_TargetDir)Microsoft.Threading.Tasks.Extensions.dll" />
      </Component>
      <Component Id="Microsoft.Threading.Tasks.dll" Guid="*">
         <File Id="Microsoft.Threading.Tasks.dll" Name="Microsoft.Threading.Tasks.dll" Source="$(var.RAMware3_TargetDir)Microsoft.Threading.Tasks.dll" />
      </Component>
      <Component Id="System.Threading.Tasks.Dataflow.dll" Guid="*">
         <File Id="System.Threading.Tasks.Dataflow.dll" Name="System.Threading.Tasks.Dataflow.dll" Source="$(var.RAMware3_TargetDir)System.Threading.Tasks.Dataflow.dll" />
      </Component>
      <Component Id="System.Windows.Interactivity.dll" Guid="*">
         <File Id="System.Windows.Interactivity.dll" Name="System.Windows.Interactivity.dll" Source="$(var.RAMware3_TargetDir)System.Windows.Interactivity.dll" />
      </Component>
      <Component Id="GalaSoft.MvvmLight.Extras.dll" Guid="*">
         <File Id="GalaSoft.MvvmLight.Extras.dll" Name="GalaSoft.MvvmLight.Extras.dll" Source="$(var.RAMware3_TargetDir)GalaSoft.MvvmLight.Extras.dll" />
      </Component>
      <Component Id="GalaSoft.MvvmLight.dll" Guid="*">
         <File Id="GalaSoft.MvvmLight.dll" Name="GalaSoft.MvvmLight.dll" Source="$(var.RAMware3_TargetDir)GalaSoft.MvvmLight.dll" />
      </Component>
      <Component Id="GalaSoft.MvvmLight.Platform.dll" Guid="*">
         <File Id="GalaSoft.MvvmLight.Platform.dll" Name="GalaSoft.MvvmLight.Platform.dll" Source="$(var.RAMware3_TargetDir)GalaSoft.MvvmLight.Platform.dll" />
      </Component>
   </ComponentGroup>
</Fragment>

   <Fragment>
      <ComponentGroup Id="ApplicationProgramsFolder_files" Directory="ApplicationProgramsFolder">
         <Component Id="DLLs_CyUSB.dll" Guid="*">
            <File Id="DLLs_CyUSB.dll" Name="CyUSB.dll" Source="$(var.RAMware3_TargetDir)DLLs\CyUSB.dll" />
         </Component>
         <Component Id="DLLs_Bootloader_Utils.dll" Guid="*">
            <File Id="DLLs_Bootloader_Utils.dll" Name="Bootloader_Utils.dll" Source="$(var.RAMware3_TargetDir)DLLs\Bootloader_Utils.dll" />
         </Component>
      </ComponentGroup>
   </Fragment>
</Wix>
philselmer
  • 751
  • 4
  • 22
Xanthius
  • 17
  • 5

1 Answers1

1

You will want to use the Difx extension, which you can access by adding xmlns:difx="http://schemas.microsoft.com/wix/DifxAppExtension" to the Wix tag. You will also need to add a reference to either difxapp_x86.wixlib or difxapp_x64.wixlib to your project.

You'll need to reference it like this:

<Feature Id="MyDrivers" Title="My Drivers">
   <Component Id="Drivers" Directory="DriverDir" Guid="*">
      <File Id="MyDriver.cat" Source="$(var.DriverFilesDir)\Driver\MyDriver.cat" />
      <File Id="MyDriver.inf" Source="$(var.DriverFilesDir)\Driver\MyDriver.inf" />
      <File Id="MyDriver.sys" Source="$(var.DriverFilesDir)\Driver\MyDriver.sys" KeyPath="yes" />
      <File Id="WdfCoinstaller01011.dll" Source="$(var.DriverFilesDir)\Driver\WdfCoinstaller01011.dll" />
      <difx:Driver AddRemovePrograms="no" Legacy="no" PlugAndPlayPrompt="no" Sequence='1' />
   </Component>
</Feature>

Note the <difx:Driver> tag recognizes your driver components above it, so order does matter. More information here.

You will need to change the directory of the Component tag to match something in your directory structure or you could add <Directory Id="DriverFiles" Name="Drivers" /> under your ApplicationProgramsFolder.

The Source value in the File tags uses the preprocessor variable DriverFilesDir, which you can either replace with a hard coded path, or you can set it in your project settings. Under the Build tab, to "Define preprocessor variables:", you would add something like DriverFilesDir=..\Drivers. Note multiple variables are separated by semicolons.

philselmer
  • 751
  • 4
  • 22
  • I haven't gotten around to trying this feature of WiX. Great to hear that you have used it successfully! Last time I did driver installs I believe I used dpinst.exe to complete it. – Stein Åsmul Sep 01 '17 at 18:20
  • Thanks again for this! This makes sense i just have 1 more question. What is it that this part is doing exactly -- > "$(var.DriverFilesDir) – Xanthius Sep 05 '17 at 20:25
  • That's a reference to a preprocessor variable named `DriverFilesDir`. You can hard code a path in there instead. – philselmer Sep 05 '17 at 20:52
  • @philselmer Sorry 1 more Question How is the component group line used That seams to be were my error is coming from. – Xanthius Sep 05 '17 at 21:42
  • You need to replace `DriverDir` with something from your own directory structure (like `ApplicationProgramsFolder`). – philselmer Sep 05 '17 at 22:12
  • @Xanthius, I apologize for messing this up. The ComponentGroup tag is used when referencing it elsewhere. In my project, I have a different file for my driver components, so I have a `Feature` tag that only has a `ComponentGroupRef` in it, instead of the whole component. In that case, `ComponentGroup` is wrapped in a `Fragment` tag instead of a `Feature` tag. I've updated the code in my answer to reflect the proper usage. – philselmer Sep 06 '17 at 12:31
  • @philselmer I tried the addition of the driver directory under the application folders menu but not sure if it in right place.I really am supper new to XML and Wix thanks for all your help this is huge. – Xanthius Sep 06 '17 at 15:44
  • @philselmer i have created a folder in the solution explorer under SetupProject1 that houses all .inf, .sys files ,wdfcoininstaller.dll so is that the problem. – Xanthius Sep 06 '17 at 15:47
  • If your driver is WDM, it will not use the WDF CoInstaller and you can just remove that line. If you are uncertain, look in the INF file and look for an section that ends with `.NT.CoInstallers` or just search for coinstallers. – philselmer Sep 06 '17 at 16:15
  • @philselmer Its RESUSB.NTamd64.CoInstallers, RESUSB.NTx86.CoInstallers its a coininstaller. The error I'm getting is Error 2 Unresolved reference to symbol 'Directory:DriverDir' in section ' – Xanthius Sep 06 '17 at 16:36
  • It looks like you are still missing the reference to it in the Directory tree. Where you have ``, you should add `` inside it. Also, you should verify which version of the CoInstaller your driver needs. – philselmer Sep 06 '17 at 17:04
  • @philselmer . I had it under before I Moved it just now. But Still getting the Same error. Also how do i verify version of coininstaller that is the one i was using before Wix it says version 1 – Xanthius Sep 06 '17 at 17:13
  • The code you posted does not have a Directory tag with `DriverDir`. I formatted the code in your post so it's more readable, can you update that code with your latest? Your INF should show which version (for example, mine shows `KmdfLibraryVersion = 1.11`). – philselmer Sep 06 '17 at 17:20
  • @philselmer I'm sorry to be a pain you a being so helpful about this. this line is were i'm getting the problems also same version you posted – Xanthius Sep 06 '17 at 17:25
  • The error you are getting is saying it doesn't know where the directory `DriverDir` exists. From the code you have posted, it looks like you are missing the line ``, which tells Light (the linker) where the destination for your driver files is. – philselmer Sep 06 '17 at 17:34
  • @philselmers Alright so I had a typo. But now it is saying it cannot find my .inf, .sys, coininstaller. so do i need to move the .inf etc to this directory or create a folder with that name – Xanthius Sep 06 '17 at 17:50
  • I would guess that `$(var.ProjectDir)\Drivers\` is not evaluating to what you expect. Try hard coding the path to those files (on your build machine). – philselmer Sep 06 '17 at 18:00
  • It looks like a lot of comments got removed. We're you able to get this working? – philselmer Sep 06 '17 at 23:32