如何在 Wix 安装项目中包含 .msi 格式的动态文件?

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

在我的项目中,用户需要将.lic 文件放在License 文件夹下的目标位置。但是,每次执行安装之前,都会创建一个名为 Guid 的新 .lic 文件。因此,这个新生成的 .lic 文件必须存在于目标安装文件夹中才能执行。那么,如何在 .wxs 中包含这个新 generated.lic 文件及其新名称?

在下面的代码中,.lic 文件是静态放置的。

<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>

我已经解决了下面的问题。

<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>