-
-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathServer.wxs
97 lines (93 loc) · 4.51 KB
/
Server.wxs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?xml version="1.0" encoding="UTF-8"?>
<!--
SPDX-FileCopyrightText: 2020 Frans van Dorsselaer
SPDX-License-Identifier: GPL-2.0-only
-->
<Wix
xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:fw="http://schemas.microsoft.com/wix/FirewallExtension"
>
<Fragment>
<DirectoryRef Id="APPLICATIONFOLDER" FileSource="$(var.PublishDir)">
<!--
The product name is 'usbipd-win', but our users are well aware they are
running a Windows operating system. Hence, the executable, service name,
and firewall rule do not use the '-win' postfix.
-->
<Component Id="usbipd.exe">
<File Id="usbipd.exe">
<fw:FirewallException
Id="usbipd"
Name="usbipd"
Protocol="tcp"
Port="3240"
Profile="all"
Scope="localSubnet"
Description="Allow computers on local subnets to access the USBIP Device Host service."
/>
</File>
<ServiceInstall
Type="ownProcess"
ErrorControl="ignore"
Name="usbipd"
Arguments="server"
Start="auto"
Vital="yes"
DisplayName="USBIP Device Host"
Description="Enables sharing of locally connected USB devices to other machines. If this service is stopped, clients will not be able to attach shared devices."
>
<ServiceDependency Id="VBoxUsbMon" />
</ServiceInstall>
<!-- Stop and remove the old service of version <= 0.3.1, if any -->
<ServiceControl
Id="usbipd_old"
Name="usbipd-win"
Remove="both"
Stop="both"
/>
<ServiceControl
Id="usbipd"
Name="usbipd"
Remove="uninstall"
Stop="both"
/>
<!--
The registry uses the full product name by convention.
-->
<RegistryKey Root="HKLM" Key="SOFTWARE\usbipd-win" ForceDeleteOnUninstall="yes">
<RegistryValue Name="APPLICATIONFOLDER" Type="string" Value="[APPLICATIONFOLDER]" />
<RegistryValue Name="Version" Type="string" Value="$(var.GitVersion_MajorMinorPatch)" />
<RegistryKey
Key="Devices"
ForceCreateOnInstall="yes"
/>
</RegistryKey>
<Environment
Id="PATH"
Name="PATH"
Action="set"
Permanent="no"
System="yes"
Part="last"
Value="[APPLICATIONFOLDER]"
/>
</Component>
</DirectoryRef>
<!-- This will restore the original Windows drivers for devices that were forced bound. -->
<SetProperty Id="RestoreDrivers" Value=""[#usbipd.exe]" unbind --all" Sequence="execute" Before="RestoreDrivers" />
<CustomAction Id="RestoreDrivers" BinaryKey="WixCA" DllEntry="WixQuietExec64" Return="ignore" Impersonate="no" Execute="deferred" />
<!--
This will *try to* start the service. However, unlike ServiceControl, it will not fail if it can't.
Now that usbipd depends on VBoxUsbMon, sometimes Windows requires a reboot before the service can start.
The CLI tool will inform the user if the service is not running and that a reboot should fix that.
-->
<SetProperty Id="TryStartService" Value=""[System64Folder]\sc.exe" start usbipd" Sequence="execute" Before="TryStartService" />
<CustomAction Id="TryStartService" BinaryKey="WixCA" DllEntry="WixQuietExec64" Return="ignore" Impersonate="no" Execute="deferred" />
<InstallExecuteSequence>
<!-- Condition: usbipd.exe is installed and will be uninstalled -->
<Custom Action="RestoreDrivers" After="StopServices">(?usbipd.exe=3) AND ($usbipd.exe=2)</Custom>
<!-- Condition: usbipd.exe will be (or remains) installed -->
<Custom Action="TryStartService" Before="InstallFinalize">$usbipd.exe=3</Custom>
</InstallExecuteSequence>
</Fragment>
</Wix>