Search code examples
c#wix

Get product version from a custom action


I have a Wix installer. In the Product.wxs file, I have the below piece of code:

<Product Id="*"
    Name="$(var.PRODUCT_NAME)"
    Language="1033"
    Version="!(bind.FileVersion.myDLLfile)"
    Manufacturer="$(var.CompanyName)"
    UpgradeCode="{D00BA432-7798-588A-34DF-34A65378FD45}">

In the Features.wxs, I have the myDLLfile defined as component:

<Component Id="myDLLfile"
    Guid="{30550881-053F-768D-88B7-BB9853B23C51}">
    <File Id="myDLLfile"
        Source="$(var.dllDir)\myDLLfile.dll"
        KeyPath="yes"
        Checksum="yes"/>
</Component>

Now, I would like to know if from a custom action in C# I can get that same Product Version (which corresponds to the version of the myDllfile.dll). Is it possible? If so, how?


Solution

  • The easiest way is probably to store the value in a Property and read that property in the custom action. The bind variable syntax would make setting the property easy.

       <Property Id="ThisIsASillyThingToNeedToDo" Value="!(bind.FileVersion.myDLLfile)" />