An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.
Rust androidanydeskdartflatpakflutterflutter-appsioslinuxmacosp2prdpremote-controlremote-desktoprustrust-langteamviewervncwaylandwindows
Feat. msi (#7610)
fufesou5a0333ddaf6a
diff --git a/res/msi/CustomActions/CustomActions.cpp b/res/msi/CustomActions/CustomActions.cppindex a5c49410f..f836edb3b 100644--- a/res/msi/CustomActions/CustomActions.cpp+++ b/res/msi/CustomActions/CustomActions.cpp@@ -1,5 +1,6 @@// CustomAction.cpp : Defines the entry point for the custom action.#include "pch.h"+#include <strutil.h>#include <shellapi.h>UINT __stdcall CustomActionHello(@@ -30,34 +31,40 @@ UINT __stdcall RemoveInstallFolder(DWORD er = ERROR_SUCCESS;int nResult = 0;- wchar_t szCustomActionData[256] = { 0 };- DWORD cchCustomActionData = sizeof(szCustomActionData) / sizeof(szCustomActionData[0]);+ LPWSTR installFolder = NULL;+ LPWSTR pwz = NULL;+ LPWSTR pwzData = NULL;hr = WcaInitialize(hInstall, "RemoveInstallFolder");ExitOnFailure(hr, "Failed to initialize");- MsiGetPropertyW(hInstall, L"InstallFolder", szCustomActionData, &cchCustomActionData);-- WcaLog(LOGMSG_STANDARD, "================= Remove Install Folder: %ls", szCustomActionData);+ hr = WcaGetProperty(L"CustomActionData", &pwzData);+ ExitOnFailure(hr, "failed to get CustomActionData");++ pwz = pwzData;+ hr = WcaReadStringFromCaData(&pwz, &installFolder);+ ExitOnFailure(hr, "failed to read database key from custom action data: %ls", pwz);SHFILEOPSTRUCTW fileOp;- ZeroMemory(&fileOp, sizeof(SHFILEOPSTRUCT));+ ZeroMemory(&fileOp, sizeof(SHFILEOPSTRUCT));fileOp.wFunc = FO_DELETE;- fileOp.pFrom = szCustomActionData;+ fileOp.pFrom = installFolder;fileOp.fFlags = FOF_NOCONFIRMATION | FOF_SILENT;- nResult = SHFileOperationW(&fileOp);+ nResult = SHFileOperation(&fileOp);if (nResult == 0){- WcaLog(LOGMSG_STANDARD, "The directory \"%ls\" has been deleted.", szCustomActionData);+ WcaLog(LOGMSG_STANDARD, "The directory \"%ls\" has been deleted.", installFolder);}else{- WcaLog(LOGMSG_STANDARD, "The directory \"%ls\" has not been deleted, error code: 0X%02X.", szCustomActionData, nResult);+ WcaLog(LOGMSG_STANDARD, "The directory \"%ls\" has not been deleted, error code: 0X%02X. Please refer to https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shfileoperationa for the error codes.", installFolder, nResult);}LExit:+ ReleaseStr(installFolder);+er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;return WcaFinalize(er);}diff --git a/res/msi/CustomActions/CustomActions.vcxproj b/res/msi/CustomActions/CustomActions.vcxprojindex 1d1521158..3667b3bc8 100644--- a/res/msi/CustomActions/CustomActions.vcxproj+++ b/res/msi/CustomActions/CustomActions.vcxproj@@ -10,7 +10,7 @@</ItemGroup><PropertyGroup Label="Globals"><Keyword>Win32Proj</Keyword>- <ProjectGuid>{87e7c13b-ae0e-4048-95cf-4523d510a3cd}</ProjectGuid>+ <ProjectGuid>{6b3647e0-b4a3-46ae-8757-a22ee51c1dac}</ProjectGuid><RootNamespace>CustomActions</RootNamespace><PlatformToolset>v143</PlatformToolset><WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>diff --git a/res/msi/Package/Components/RustDesk.wxs b/res/msi/Package/Components/RustDesk.wxsindex abb43358d..297f35a77 100644--- a/res/msi/Package/Components/RustDesk.wxs+++ b/res/msi/Package/Components/RustDesk.wxs@@ -20,6 +20,7 @@<SetProperty Id="RestartService" Value=""net" start $(var.Product)" Before="RestartService" Sequence="execute" /><CustomAction Id="RestartService" DllEntry="WixQuietExec" Execute="deferred" Return="asyncWait" BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)" />+ <CustomAction Id="RemoveInstallFolder.SetParam" Return="check" Property="RemoveInstallFolder" Value="[INSTALLFOLDER]" /><InstallExecuteSequence><!--The ServiceControl element above handles starting/stopping the server on install/uninstall,@@ -30,8 +31,8 @@<Custom Action="CustomActionHello" Before="InstallFinalize" />- <Custom Action="SetInstallFolder" After="RemoveFiles"/>- <Custom Action="RemoveInstallFolder" After="SetInstallFolder"/>+ <Custom Action="RemoveInstallFolder.SetParam" After="RemoveFiles"/>+ <Custom Action="RemoveInstallFolder" After="RemoveInstallFolder.SetParam"/></InstallExecuteSequence><!-- Shortcuts -->diff --git a/res/msi/Package/Fragments/CustomActions.wxs b/res/msi/Package/Fragments/CustomActions.wxsindex 79b49b49d..09d9b5698 100644--- a/res/msi/Package/Fragments/CustomActions.wxs+++ b/res/msi/Package/Fragments/CustomActions.wxs@@ -5,18 +5,15 @@<Binary Id="Custom_Actions_Dll" SourceFile="$(var.CustomActions.TargetDir)$(var.CustomActions.TargetName).dll" /><CustomAction Id="CustomActionHello" DllEntry="CustomActionHello" Impersonate="yes" Execute="immediate" Return="ignore" BinaryRef="Custom_Actions_Dll"/>- <CustomAction Id="RemoveInstallFolder" DllEntry="RemoveInstallFolder" Impersonate="no" Execute="immediate" Return="ignore" BinaryRef="Custom_Actions_Dll"/>-- <Property Id="InstallFolder" Value="C:\Programe Files\$(var.Product)" />- <CustomAction Id="SetInstallFolder" Property="InstallFolder" Value="[INSTALLFOLDER]" />+ <CustomAction Id="RemoveInstallFolder" DllEntry="RemoveInstallFolder" Impersonate="no" Execute="deferred" Return="ignore" BinaryRef="Custom_Actions_Dll"/><!-- Use WixQuietExec to run the commands to avoid the command window popping up. The command line to run needs to be storedin a property with the same id as the WixQuietExec custom action and the path to the exe needs to be quoted.A SetProperty action is used to allow the [SystemFolder] reference to be resolved and needs to be scheduled to run before the action.-->- <SetProperty Id="FirewallPortOutAdd" Value=""[SystemFolder]netsh.exe" advfirewall firewall add rule name="$(var.Product) Service" dir=out action=allow programe=$(var.ProductLower) enable=yes" Before="FirewallPortOutAdd" Sequence="execute" />+ <SetProperty Id="FirewallPortOutAdd" Value=""[SystemFolder]netsh.exe" advfirewall firewall add rule name="$(var.Product) Service" dir=out action=allow program=$(var.ProductLower) enable=yes" Before="FirewallPortOutAdd" Sequence="execute" /><CustomAction Id="FirewallPortOutAdd" DllEntry="WixQuietExec" Execute="deferred" Return="asyncWait" BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)" />- <SetProperty Id="FirewallPortInAdd" Value=""[SystemFolder]netsh.exe" advfirewall firewall add rule name="$(var.Product) Service" dir=in action=allow programe=$(var.ProductLower) enable=yes" Before="FirewallPortInAdd" Sequence="execute" />+ <SetProperty Id="FirewallPortInAdd" Value=""[SystemFolder]netsh.exe" advfirewall firewall add rule name="$(var.Product) Service" dir=in action=allow program=$(var.ProductLower) enable=yes" Before="FirewallPortInAdd" Sequence="execute" /><CustomAction Id="FirewallPortInAdd" DllEntry="WixQuietExec" Execute="deferred" Return="asyncWait" BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)" /><SetProperty Id="FirewallPortRemove" Value=""[SystemFolder]netsh.exe" advfirewall firewall delete rule name="$(var.Product) Service"" Before="FirewallPortRemove" Sequence="execute" />diff --git a/res/msi/msi.sln b/res/msi/msi.slnindex 8fb06eb51..70d28fb86 100644--- a/res/msi/msi.sln+++ b/res/msi/msi.sln@@ -5,38 +5,17 @@ VisualStudioVersion = 17.7.34003.232MinimumVisualStudioVersion = 10.0.40219.1Project("{B7DD6F7E-DEF8-4E67-B5B7-07EF123DB6F0}") = "Package", "Package\Package.wixproj", "{F403A403-CEFF-4399-B51C-CC646C8E98CF}"EndProject-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CustomActions", "CustomActions\CustomActions.vcxproj", "{87E7C13B-AE0E-4048-95CF-4523D510A3CD}"+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CustomActions", "CustomActions\CustomActions.vcxproj", "{6B3647E0-B4A3-46AE-8757-A22EE51C1DAC}"EndProjectGlobalGlobalSection(SolutionConfigurationPlatforms) = preSolution- Debug|Any CPU = Debug|Any CPU- Debug|x64 = Debug|x64- Debug|x86 = Debug|x86- Release|Any CPU = Release|Any CPURelease|x64 = Release|x64- Release|x86 = Release|x86EndGlobalSectionGlobalSection(ProjectConfigurationPlatforms) = postSolution- {F403A403-CEFF-4399-B51C-CC646C8E98CF}.Debug|Any CPU.ActiveCfg = Release|x64- {F403A403-CEFF-4399-B51C-CC646C8E98CF}.Debug|Any CPU.Build.0 = Release|x64- {F403A403-CEFF-4399-B51C-CC646C8E98CF}.Debug|x64.ActiveCfg = Release|x64- {F403A403-CEFF-4399-B51C-CC646C8E98CF}.Debug|x64.Build.0 = Release|x64- {F403A403-CEFF-4399-B51C-CC646C8E98CF}.Debug|x86.ActiveCfg = Release|x64- {F403A403-CEFF-4399-B51C-CC646C8E98CF}.Debug|x86.Build.0 = Release|x64- {F403A403-CEFF-4399-B51C-CC646C8E98CF}.Release|Any CPU.ActiveCfg = Release|x64- {F403A403-CEFF-4399-B51C-CC646C8E98CF}.Release|Any CPU.Build.0 = Release|x64{F403A403-CEFF-4399-B51C-CC646C8E98CF}.Release|x64.ActiveCfg = Release|x64{F403A403-CEFF-4399-B51C-CC646C8E98CF}.Release|x64.Build.0 = Release|x64- {F403A403-CEFF-4399-B51C-CC646C8E98CF}.Release|x86.ActiveCfg = Release|x64- {F403A403-CEFF-4399-B51C-CC646C8E98CF}.Release|x86.Build.0 = Release|x64- {87E7C13B-AE0E-4048-95CF-4523D510A3CD}.Debug|Any CPU.ActiveCfg = Release|x64- {87E7C13B-AE0E-4048-95CF-4523D510A3CD}.Debug|x64.ActiveCfg = Release|x64- {87E7C13B-AE0E-4048-95CF-4523D510A3CD}.Debug|x86.ActiveCfg = Release|x64- {87E7C13B-AE0E-4048-95CF-4523D510A3CD}.Release|Any CPU.ActiveCfg = Release|x64- {87E7C13B-AE0E-4048-95CF-4523D510A3CD}.Release|Any CPU.Build.0 = Release|x64- {87E7C13B-AE0E-4048-95CF-4523D510A3CD}.Release|x64.ActiveCfg = Release|x64- {87E7C13B-AE0E-4048-95CF-4523D510A3CD}.Release|x64.Build.0 = Release|x64- {87E7C13B-AE0E-4048-95CF-4523D510A3CD}.Release|x86.ActiveCfg = Release|x64+ {6B3647E0-B4A3-46AE-8757-A22EE51C1DAC}.Release|x64.ActiveCfg = Release|x64+ {6B3647E0-B4A3-46AE-8757-A22EE51C1DAC}.Release|x64.Build.0 = Release|x64EndGlobalSectionGlobalSection(SolutionProperties) = preSolutionHideSolutionNode = FALSEdiff --git a/res/msi/preprocess.py b/res/msi/preprocess.pyindex fe9050b98..23f1e28ea 100644--- a/res/msi/preprocess.py+++ b/res/msi/preprocess.py@@ -143,7 +143,7 @@ def gen_upgrade_info(version):upgrade_id = uuid.uuid4()to_insert_lines = [f'{indent}<Upgrade Id="{upgrade_id}">\n',- f'{indent}<UpgradeVersion Property="OLD_VERSION_FOUND" Minimum="{major}.0.0.0" Maximum="{major}.99.99" IncludeMinimum="yes" IncludeMaximum="yes" OnlyDetect="no" IgnoreRemoveFailure="yes" MigrateFeatures="yes" />" ?>\n',+ f'{indent}{g_indent_unit}<UpgradeVersion Property="OLD_VERSION_FOUND" Minimum="{major}.0.0.0" Maximum="{major}.99.99" IncludeMinimum="yes" IncludeMaximum="yes" OnlyDetect="no" IgnoreRemoveFailure="yes" MigrateFeatures="yes" />\n',f"{indent}</Upgrade>\n",]