NetInverse Developers Blog

April 3, 2009
Category: WiX — Tags: , , , , — admin @ 9:36 pm

Today I would like to show you how to create a WiX file that installs a COM DLL. In this WiX sample, WiX copies the DLL file to a target directory and perform COM component registration for you.

Let’s use the previous WiX sample project - product.wxs again:

  1. This WiX sample creates an MSI that copies readme.txt into
    %sysdrv%/program files/test program/
    <?xml version='1.0'?>
    <WiX xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>
       <Product Id='12345678-1234-1234-1234-123456789012' Name='Test Package' Language='1033'
                Version='1.0.0.0' Manufacturer='Microsoft Corporation'>
          <Package Id='12345678-1234-1234-1234-123456789012'
                    Description='My first Windows Installer package'
                    Comments='This is my first attempt at creating a Windows Installer database'
                    Manufacturer='Microsoft Corporation' InstallerVersion='200' Compressed='yes' />
    
          <Media Id='1' Cabinet='product.cab' EmbedCab='yes' />
    
          <Directory Id='TARGETDIR' Name='SourceDir'>
             <Directory Id='ProgramFilesFolder' Name='PFiles'>
                <Directory Id='MyDir' Name='TestProg' LongName='Test Program'>
                   <Component Id='MyComponent' Guid='12345678-1234-1234-1234-123456789012'>
                      <File Id='readme' Name='readme.txt' DiskId='1' src='readme.txt' />
                   </Component>
                </Directory>
             </Directory>
          </Directory>
    
          <Feature Id='MyFeature' Title='My 1st Feature' Level='1'>
             <ComponentRef Id='MyComponent' />
          </Feature>
       </Product>
    </WiX>

    Now we modify the above WiX sample to install a COM DLL. Add the red part into it:

    <?xml version='1.0'?>
    <WiX xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>
       <Product Id='12345678-1234-1234-1234-123456789012' Name='Test Package' Language='1033'
                Version='1.0.0.0' Manufacturer='Microsoft Corporation'>
          <Package Id='12345678-1234-1234-1234-123456789012'
                    Description='My first Windows Installer package'
                    Comments='This is my first attempt at creating a Windows Installer database'
                    Manufacturer='Microsoft Corporation' InstallerVersion='200' Compressed='yes' />
    
          <Media Id='1' Cabinet='product.cab' EmbedCab='yes' />
    
          <Directory Id='TARGETDIR' Name='SourceDir'>
             <Directory Id='ProgramFilesFolder' Name='PFiles'>
                <Directory Id='MyDir' Name='TestProg' LongName='Test Program'>
                   <Component Id='MyComponent' Guid='12345678-1234-1234-1234-123456789012'>
                      <File Id='readme' Name='readme.txt' DiskId='1' src='readme.txt' />
                      <File Id='DLL' Name='fupload.DLL' DiskId='1' src='c:fupload.DLL' SelfRegCost="1" />
                   </Component>
                </Directory>
             </Directory>
          </Directory>
    
          <Feature Id='MyFeature' Title='My 1st Feature' Level='1'>
             <ComponentRef Id='MyComponent' />
          </Feature>
       </Product>
    </WiX>
    
  2. Compile the WiX file with Candle. Candle is the compiler used to compile the XML documents to object files that contain symbols and references to symbols.
    c:wixcandle product.wxs
  3. Link WiXObj file into MSI with Light. Light is a linker takes one or more object files and links the references in the object files to the appropriate symbols in other object files. Light is also responsible for collecting all of the binaries, packaging them appropriately, and generating the final MSI or MSM file.
    c:wixlight product.wixobj

    Since you don’t have the COM DLL: fupload.DLL under c:, you will get a link error. You can use any COM DLL available and just change the example accordingly.

  4. Test your MSI created:Install the MSI by running:
    c:wixmsiexec /i product.msi

    Goto %sysdrv%/program files/test program/, you will see the file readme.txt and fupload.DLL. Run regedit,exe, search fupload.DLL, you will see that the COM DLL has been registered properly. Is it cool?

    You can uninstall the MSI by running:

    c:wixmsiexec /x product.msi

Please check out other WiX samples.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

©2009 NetInverse. All rights reserved. Powered by WordPress