Search code examples
wixwindows-installerwix3velo

how to show the version number when we hover on the .msi file using WIX


When the mouse hovers over the .msi file, a tooltip should popup that shows the version of the application:

Version Number on Hover for MSI

I want to display version number within this description box so what can I add in my code so that I got this version number in this box when I hover over the .msi file.


Solution

  • PUT-GUID-HERE: For all samples, replace "PUT-GUID-HERE" with a GUID. You can generate one here: https://www.guidgenerator.com/


    There could be an easier way to do this, but it seems to be possible to "re-purpose" the Comments attribute in the Package element for this - here is a snippet, the relevant part is the "Comments" attribute:

    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Comments="Version: 1.0.993" />
    

    Screen shot:

    MSI Hover

    Full Sample:

    <?xml version="1.0" encoding="UTF-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
        <Product Id="*" Name="HoverVersionNumber" Language="1033" Version="1.0.993" 
                        Manufacturer="Tester" UpgradeCode="PUT-GUID-HERE">
        
            <Package InstallerVersion="200" Compressed="yes"
                     InstallScope="perMachine" Comments="Version: 1.0.993" />
    
            <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
            <MediaTemplate EmbedCab="yes" />
    
            <Feature Id="ProductFeature" Title="HoverVersionNumber" Level="1" />
    
      <Directory Id="TARGETDIR" Name="SourceDir">
          <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLFOLDER" Name="HoverVersionNumber">
              
              <Component Feature="ProductFeature">
                <File Source="C:\Windows\Notepad.exe" />
              </Component>
            
          </Directory>
          </Directory>
        </Directory>
    
      </Product>
    
    </Wix>
    

    Now using a preprocessor define entry to allow version number to be set once and applied wherever needed - the $(var.MyVersion) markup will expand to the version number in the define statement (allowing a single location to update the version number provided the markup is up to date everywhere in the source):

    Snippets:

      <?define MyVersion  = "1.0.993"?>
    
      <..>
    
      <Product Id="*" Name="HoverVersionNumber" Language="1033" Version="$(var.MyVersion)" 
               Manufacturer="Tester" UpgradeCode="PUT-GUID-HERE">
        
        <Package InstallerVersion="200" Compressed="yes" 
                 InstallScope="perMachine" Comments="Version: $(var.MyVersion)" />
    

    Full Sample:

    <?xml version="1.0" encoding="UTF-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    
      <?define MyVersion  = "1.0.993"?>
      
        <Product Id="*" Name="HoverVersionNumber" Language="1033" Version="$(var.MyVersion)" 
                 Manufacturer="Tester" UpgradeCode="PUT-GUID-HERE">
        
            <Package InstallerVersion="200" Compressed="yes" 
                     InstallScope="perMachine" Comments="Version: $(var.MyVersion)" />
    
            <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
            <MediaTemplate EmbedCab="yes" />
    
            <Feature Id="ProductFeature" Title="HoverVersionNumber" Level="1" />
    
      <Directory Id="TARGETDIR" Name="SourceDir">
          <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLFOLDER" Name="HoverVersionNumber">
              
              <Component Feature="ProductFeature">
                <File Source="C:\Windows\Notepad.exe" />
              </Component>
            
          </Directory>
          </Directory>
        </Directory>
    
      </Product>
    
    </Wix>