How can I include a dynamic file in .msi in a Wix setup project?

171 Views Asked by At

In my project user needs to place .lic file in the target location under License folder. However, each time before an install executed, a new .lic file with a name of Guid created. So, this newly generated .lic file has to be existed in the target install folder in order to be executed. So, how can I include this newly generated.lic file with its new name in .wxs?

In the code below, .lic files are placed statically.

<Directory Id="dir2DD9EA0D815007578196EFA27F567092" Name="Licenses">`enter code here`                       
                    <Directory Id="dirD6EBD685D90950A0F304F5EFBC293201" Name="Devices">
                        <Component Id="cmp1BA173B1588EF11B24651E2C57684F41" Guid="{0AC7B82B-E85A-42B8-8156-3A435DEF7868}">
                            <File Id="fil1AD590AF499331F0C3BF14DC51B62411" KeyPath="yes" Source="$(var.GatewayPath)\Licenses\Devices\{7e173bee-e914-4a07-8500-595ee9757047}.lic" />
                        </Component>
                        <Component Id="cmpB1DF42E330453DC4C24E213ED65887EC" Guid="{6B6F5A3E-3DD4-46AB-A35B-E5B0E784756F}">
                            <File Id="fil61099F899D843C9EC784909DF6C50A19" KeyPath="yes" Source="$(var.GatewayPath)\Licenses\Devices\{b16e6bfc-c8fb-45b1-be2f-e949446d5415}.lic" />
                        </Component>
                    </Directory>
                </Directory>
1

There are 1 best solutions below

0
On BEST ANSWER

I have solved my problem as below.

<Directory Id="dirD6EBD685D90950A0F304F5EFBC293201" Name="Devices">                         
    <Component Id="CopyLicensesComponent" Guid="A7C42303-1D77-4C70-8D5C-0FD0F9158EB4" >
        <CopyFile Id="LicenseFileCopy" SourceProperty="SOURCEDIRECTORY" DestinationDirectory="dirD6EBD685D90950A0F304F5EFBC293201" SourceName="*.lic" />
    </Component>
</Directory>