Tauri 使用WiX片段扩展安装程序

2023-10-17 18:01 更新

WiX片段是一个容器,您可以在其中配置几乎所有WiX提供的功能。在本例中,我们将定义一个片段,用于编写两个注册表条目:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<!-- these registry entries should be installed
to the target user's machine -->
<DirectoryRef Id="TARGETDIR">
<!-- groups together the registry entries to be installed -->
<!-- Note the unique `Id` we provide here -->
<Component Id="MyFragmentRegistryEntries" Guid="*">
<!-- the registry key will be under
HKEY_CURRENT_USER\Software\MyCompany\MyApplicationName -->
<!-- Tauri uses the second portion of the
bundle identifier as the `MyCompany` name
(e.g. `tauri-apps` in `com.tauri-apps.test`) -->
<RegistryKey
Root="HKCU"
Key="Software\MyCompany\MyApplicationName"
Action="createAndRemoveOnUninstall"
>
<!-- values to persist on the registry -->
<RegistryValue
Type="integer"
Name="SomeIntegerValue"
Value="1"
KeyPath="yes"
/>
<RegistryValue Type="string" Value="Default Value" />
</RegistryKey>
</Component>
</DirectoryRef>
</Fragment>
</Wix>

将片段文件保存为带有.wxs扩展名的文件,并在项目的某个位置引用它在tauri.conf.json中:

{
"tauri": {
"bundle": {
"windows": {
"wix": {
"fragmentPaths": ["./path/to/registry.wxs"],
"componentRefs": ["MyFragmentRegistryEntries"]
}
}
}
}
}

请注意,ComponentGroupComponentFeatureGroupFeatureMerge元素的id必须在tauri.conf.jsoncomponentGroupRefscomponentRefsfeatureGroupRefsfeatureRefsmergeRefs中进行引用,以便包含在安装程序中。


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号