NetInverse Developers Blog

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

Today I will show you how to log tracing information from your custom actions into your MSI’s log. We will still use the product.wxs sample. You can follow the steps below:

  1. Create an xml file: product.wxs (copied from WiX.chm)  as below
    This WiX file will create an MSI file to copy 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>
          <InstallExecuteSequence>
             <Custom Action="test" Sequence='1'/>
          </InstallExecuteSequence>
    
          <Binary Id='Customization.vbs' src='Customization.vbs'/>
          <CustomAction Id='test' BinaryKey='Customization.vbs' VBScriptCall='Hello' Return='check'/>
       </Product>
    </WiX>
  2. Create a customization VBS code: Customization.vbs
                   Function LogInfo(msg) Dim rec
                        Set rec = Session.Installer.CreateRecord(1)
                        rec.StringData(0) = msg
                        LogInfo = Session.Message(&H04000000, rec)
                    End Function
    
                    Function Hello
                        LogInfo "Customization is being called here."
                    End function
  3. Compile:
    c:\WiX\candle product.wxs
  4. Link:
    c:\WiX\light product.WiXobj
  5. Test your MSI:
    c:\WiX\msiexec /i product.msi /L*v log.txt

Open log.txt, search “Customization is being called here” to locate your the tracing information. Now you can log your debugging information to the calling MSI’s log file for diagnostics.

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