InventoryAgent/Inventory.Installer/Product.wxs
2025-10-20 00:03:49 +08:00

128 lines
6.1 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui"
xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
<Package Name="Inventory Suite" Language="1033" Version="1.0.0.0" Manufacturer="YourCompany" UpgradeCode="cdacf8ca-bc77-48cf-9d80-eae508b484fb" Compressed="yes">
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<!-- Define public properties for service account credentials -->
<Property Id="SERVICEACCOUNT_USER" Secure="yes" />
<Property Id="SERVICEACCOUNT_PASSWORD" Secure="yes" Hidden="yes" />
<!-- Add reference to the WixUI library -->
<ui:WixUI Id="WixUI_InstallDir" />
<UI>
<DialogRef Id="ServiceAccountDialog" />
<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="ServiceAccountDialog" />
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="ServiceAccountDialog" />
</UI>
<Feature Id="ProductFeature" Title="Inventory.Installer" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<ComponentGroupRef Id="VaultComponents" />
<ComponentGroupRef Id="AgentComponents" />
<ComponentGroupRef Id="AdminToolComponents" />
<ComponentRef Id="ApplicationShortcut" />
<ComponentRef Id="DesktopShortcut" />
</Feature>
</Package>
<Fragment>
<!-- C:\Program Files\InventorySuite -->
<StandardDirectory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="InventorySuite">
<Directory Id="AGENT_DIR" Name="Agent" />
<Directory Id="ADMINTOOL_DIR" Name="AdminTool" />
</Directory>
</StandardDirectory>
<!-- C:\ProgramData\InventorySuite\Vault -->
<StandardDirectory Id="CommonAppDataFolder">
<Directory Id="AppDataInventorySuite" Name="InventorySuite">
<Directory Id="VAULTDATAFOLDER" Name="Vault" />
</Directory>
</StandardDirectory>
<!-- Start Menu Shortcut -->
<StandardDirectory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="Inventory Suite"/>
</StandardDirectory>
<!-- DesktopFolder is a standard directory and does not need to be defined here. -->
</Fragment>
<Fragment>
<!-- Vault Components -->
<ComponentGroup Id="VaultComponents" Directory="VAULTDATAFOLDER">
<!-- Component for the configuration file. Keep it permanent and don't overwrite on upgrade. -->
<Component Id="VaultHclFileComponent" Guid="*" Permanent="yes" NeverOverwrite="yes">
<File Id="VaultHclFile" Source="$(var.Inventory.Core.TargetDir)vault.hcl" KeyPath="yes" Hidden="yes" />
</Component>
<Component Id="VaultExeComponent" Guid="*">
<File Id="VaultExeFile" Source="$(var.Inventory.Core.TargetDir)vault.exe" KeyPath="yes" Hidden="yes" />
</Component>
<Component Id="VaultOtherFiles" Guid="*">
<!-- Add other files from Inventory.Core output here, e.g., DLLs -->
<!-- Example: <File Source="$(var.Inventory.Core.TargetDir)SomeOther.dll" Hidden="yes" /> -->
<RegistryValue Root="HKLM" Key="Software\YourCompany\InventorySuite" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</ComponentGroup>
<!-- Agent Components -->
<ComponentGroup Id="AgentComponents" Directory="AGENT_DIR">
<Component Id="AgentService" Guid="*">
<File Id="AgentExe" Source="$(var.Inventory.Agent.TargetDir)Inventory.Agent.exe" KeyPath="yes" />
<!-- Just grant the logon right. Don't manage the user account itself. -->
<util:User Id="ServiceAccountUser" Name="[SERVICEACCOUNT_USER]" LogonAsService="yes" />
<ServiceInstall Id="ServiceInstaller"
Type="ownProcess"
Vital="yes"
Name="InventoryAgent"
DisplayName="Inventory Agent Service"
Description="Collects and reports system inventory information."
Start="auto"
Account="[SERVICEACCOUNT_USER]"
Password="[SERVICEACCOUNT_PASSWORD]" />
<ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="InventoryAgent" Wait="yes" />
</Component>
<!-- Add other agent files here -->
<Component Id="AgentOtherFiles" Guid="*">
<File Id="AgentCoreDll" Source="$(var.Inventory.Core.TargetPath)" KeyPath="yes" />
</Component>
</ComponentGroup>
<!-- Admin Tool Components -->
<ComponentGroup Id="AdminToolComponents" Directory="ADMINTOOL_DIR">
<Component Id="AdminToolExe" Guid="*">
<File Id="AdminToolExeFile" Source="$(var.Inventory.AdminTool.TargetDir)Inventory.AdminTool.exe" KeyPath="yes" />
</Component>
<!-- Add other admin tool files here -->
</ComponentGroup>
<!-- Desktop Shortcut Component -->
<Component Id="ApplicationShortcut" Directory="ApplicationProgramsFolder" Guid="*">
<!-- Create a shortcut in the Start Menu -->
<Shortcut Id="ApplicationStartMenuShortcut" Name="Inventory Admin Tool" Description="Inventory Administration Tool" Target="[ADMINTOOL_DIR]Inventory.AdminTool.exe" WorkingDirectory="ADMINTOOL_DIR"/>
<!-- This component creates the folder, so it must also remove it. -->
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\YourCompany\InventorySuite" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
<Component Id="DesktopShortcut" Directory="DesktopFolder" Guid="*">
<Shortcut Id="ApplicationDesktopShortcut" Name="Inventory Admin Tool" Description="Inventory Administration Tool" Target="[ADMINTOOL_DIR]Inventory.AdminTool.exe" WorkingDirectory="ADMINTOOL_DIR"/>
<RegistryValue Root="HKCU" Key="Software\YourCompany\InventorySuite\DesktopShortcut" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</Fragment>
<!-- Include the custom dialog -->
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent"> -->
<!-- TODO: Insert files, registry keys, and other resources here. -->
<!-- </Component> -->
</ComponentGroup>
</Fragment>
</Wix>