Attempt to set file associations and fire-wall exceptions.

The fire-wall exceptions work, but the device needs to be restarted. Is that worth it?

A more important problem is that windows overhauled the file associations a few years ago. The approach here doesn't work (but is at least consistent with how it worked before, so it might work for Windows < 10 or unupdated). The current go-to approach is the one used by firefox, and it happens after the installer, at first start-up of the program.

part of CURA-9157
This commit is contained in:
Remco Burema 2022-12-29 18:06:53 +01:00
parent ddd7ac58b0
commit 5b8bac6a61
3 changed files with 48 additions and 27 deletions

View File

@ -27,7 +27,6 @@
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)"> <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish> <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control> </Control>
<Control Id="DesktopShortcutCheckBox" Type="CheckBox" X="20" Y="160" Width="290" Height="17" Property="PREVIOUS_VERSIONS_INSTALLED" CheckBoxValue="0" Text="Uninstall previous Cura versions." />
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.CustomizeDlgBannerBitmap)" /> <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.CustomizeDlgBannerBitmap)" />
<Control Id="Text" Type="Text" X="25" Y="55" Width="320" Height="20" Text="!(loc.CustomizeDlgText)" /> <Control Id="Text" Type="Text" X="25" Y="55" Width="320" Height="20" Text="!(loc.CustomizeDlgText)" />
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" /> <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
@ -41,6 +40,7 @@
<Control Id="ItemSize" Type="Text" X="215" Y="140" Width="131" Height="50" Text="!(loc.CustomizeDlgItemSize)"> <Control Id="ItemSize" Type="Text" X="215" Y="140" Width="131" Height="50" Text="!(loc.CustomizeDlgItemSize)">
<Subscribe Event="SelectionSize" Attribute="Text" /> <Subscribe Event="SelectionSize" Attribute="Text" />
</Control> </Control>
<Control Id="UninstallPreviousCheckBox" Type="CheckBox" X="10" Y="210" Width="290" Height="17" Property="PREVIOUS_VERSIONS_INSTALLED" CheckBoxValue="0" Text="Uninstall previous Cura versions." />
<Control Id="Location" Type="Text" X="90" Y="210" Width="200" Height="20" Text="!(loc.CustomizeDlgLocation)"> <Control Id="Location" Type="Text" X="90" Y="210" Width="200" Height="20" Text="!(loc.CustomizeDlgLocation)">
<Subscribe Event="SelectionPath" Attribute="Text" /> <Subscribe Event="SelectionPath" Attribute="Text" />
<Subscribe Event="SelectionPathOn" Attribute="Visible" /> <Subscribe Event="SelectionPathOn" Attribute="Visible" />

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:fw="http://schemas.microsoft.com/wix/FirewallExtension">
<Product <Product
Id="*" Id="*"
Name="{{ app_name }}" Name="{{ app_name }}"
@ -14,7 +14,7 @@
Manufacturer="{{ company }}" Manufacturer="{{ company }}"
Description="UltiMaker Cura the most popular 3D printing slicer" Description="UltiMaker Cura the most popular 3D printing slicer"
Keywords="UltiMaker,Cura,3D,printing,slicer" Keywords="UltiMaker,Cura,3D,printing,slicer"
Comments="Copyright (c) {{ year }} UltiMaker" /> Comments="Copyright (c) {{ year }} UltiMaker B.V." />
<InstallExecuteSequence> <InstallExecuteSequence>
<RemoveExistingProducts Before="InstallInitialize" /> <RemoveExistingProducts Before="InstallInitialize" />
@ -86,26 +86,43 @@
<Property Id="ApplicationFolderName" Value="{{ app_name }} {{ version }}" /> <Property Id="ApplicationFolderName" Value="{{ app_name }} {{ version }}" />
<Property Id="WixAppFolder" Value="WixPerMachineFolder" /> <Property Id="WixAppFolder" Value="WixPerMachineFolder" />
<Component Id="CMP_UltiMaker_Cura_exe" Directory="APPLICATIONFOLDER" Guid="*"> <Component Id="CMP_UltiMaker_Cura_exe" Directory="APPLICATIONFOLDER" Guid="*">
<File Id="FILE_UltiMaker_Cura_exe" KeyPath="yes" Source="$(var.CuraDir)\{{ main_app }}" /> <File Id="FILE_UltiMaker_Cura_exe" KeyPath="yes" Source="$(var.CuraDir)\{{ main_app }}"/>
<!--Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\PackageRepository\Extensions\windows.fileTypeAssociation\.3mf-->
<!--Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\PackageRepository\Extensions\windows.fileTypeAssociation\.3mf--> <RegistryValue Root="HKLM" Key="SOFTWARE\{{ app_name }}\Capabilities\FileAssociations" Name=".3mf" Value="PRG_UltiMaker_Cura.3MF" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\{{ app_name }}\Capabilities\FileAssociations" Name=".stl" Value="PRG_UltiMaker_Cura.STL" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\{{ app_name }}\Capabilities\MIMEAssociations" Name="application/3mf" Value="PRG_UltiMaker_Cura.3MF" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\{{ app_name }}\Capabilities\MIMEAssociations" Name="application/stl" Value="PRG_UltiMaker_Cura.STL" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\{{ app_name }}\Capabilities\shell\Open\command" Value='"[APPLICATIONFOLDER]\{{ main_app }}" "%1"' Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\RegisteredApplications" Name="{{ app_name }}" Value="SOFTWARE\MyApp\Capabilities" Type="string" />
<ProgId Id="PRG_UltiMaker_Cura" Description="{{ app_name }}" Icon="ICO_Cura" Advertise="yes"> <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\{{ main_app }}\SupportedTypes" Name=".3mf" Value="" Type="string" />
<Extension Id="stl"> <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\{{ main_app }}\SupportedTypes" Name=".stl" Value="" Type="string" />
<Verb Id='open' Command="[APPLICATIONFOLDER]{{ main_app }}" Argument='"%1"' /> <RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\{{ main_app }}\shell\open" Name="{{ app_name }}" Value="{{ main_app }}" Type="string" />
<MIME Advertise="yes" ContentType="application/stl" Default="yes" />
</Extension> <ProgId Id="PRG_UltiMaker_Cura.STL" Description="{{ app_name }}" Icon="FILE_UltiMaker_Cura_exe">
<Extension Id="3mf"> <Extension Id="STL">
<Verb Id='open' Command="[APPLICATIONFOLDER]{{ main_app }}" Argument='"%1"' /> <Verb Id='edit' TargetFile="FILE_UltiMaker_Cura_exe" Argument='"%1"' />
<MIME Advertise="yes" ContentType="application/3mf" Default="yes" /> <MIME ContentType="application/stl" Default="yes" />
</Extension> </Extension>
</ProgId> </ProgId>
</Component> <ProgId Id="PRG_UltiMaker_Cura.3MF" Description="{{ app_name }}" Icon="FILE_UltiMaker_Cura_exe">
<Component Id="CMP_CuraEngine_exe" Directory="APPLICATIONFOLDER" Guid="*"> <Extension Id="3MF">
<File Id="FILE_CuraEngine_exe" KeyPath="yes" Source="$(var.CuraDir)\CuraEngine.exe" /> <Verb Id='edit' TargetFile="FILE_UltiMaker_Cura_exe" Argument='"%1"' />
<!--TODO: add firewall exception, see: https://wixtoolset.org/docs/v3/xsd/firewall/firewallexception/--> <MIME ContentType="application/3mf" Default="yes" />
</Component> </Extension>
</ProgId>
<!-- Current Cura versions are not supported on XP or Server 2003. Even so, add 'ignorefailure=yes'. After all, worst that can happen is the user gets asked, like before. -->
<fw:FirewallException Id="FirewallExceptLocalFrontend" Name="Cura (Frontend) Connection (LocalHost)" File="FILE_CuraEngine_exe" Port="127.0.0.1" IgnoreFailure="yes" Scope="localSubnet" />
</Component>
<Component Id="CMP_CuraEngine_exe" Directory="APPLICATIONFOLDER" Guid="*">
<File Id="FILE_CuraEngine_exe" KeyPath="yes" Source="$(var.CuraDir)\CuraEngine.exe" />
<!-- Current Cura versions are not supported on XP or Server 2003. Even so, add 'ignorefailure=yes'. After all, worst that can happen is the user gets asked, like before. -->
<fw:FirewallException Id="FirewallExceptLocalEngine" Name="CuraEngine (Backend) Connection (LocalHost)" File="FILE_CuraEngine_exe" Port="127.0.0.1" IgnoreFailure="yes" Scope="localSubnet" />
</Component>
<!--Shortcuts--> <!--Shortcuts-->
<DirectoryRef Id="ShortCutDir"> <DirectoryRef Id="ShortCutDir">
@ -113,7 +130,7 @@
<Shortcut Id="SHRT_Cura" <Shortcut Id="SHRT_Cura"
Name="{{ app_name }} {{ version }}" Name="{{ app_name }} {{ version }}"
Description="{{ app_name }} {{ version }}" Description="{{ app_name }} {{ version }}"
Target="[APPLICATIONFOLDER]{{ main_app }}" Target="[APPLICATIONFOLDER]\{{ main_app }}"
Icon="ICO_Cura" /> Icon="ICO_Cura" />
<Shortcut Id="SHRT_UninstallShortcut" <Shortcut Id="SHRT_UninstallShortcut"
Name="Uninstall {{ app_name }} {{ version }}" Name="Uninstall {{ app_name }} {{ version }}"

View File

@ -87,13 +87,17 @@ def build(dist_path: Path, filename: str):
"-out", f"{heat_loc.as_posix()}"] "-out", f"{heat_loc.as_posix()}"]
subprocess.call(heat_command) subprocess.call(heat_command)
build_command = ["candle", "-arch", "x64", f"-dCuraDir={dist_loc}\\", "-out", f"{build_loc.as_posix()}\\", build_command = ["candle", "-arch", "x64", f"-dCuraDir={dist_loc}\\",
"-ext", "WixFirewallExtension",
"-out", f"{build_loc.as_posix()}\\",
f"{wxs_loc.as_posix()}", f"{heat_loc.as_posix()}", f"{manageoldcuradlg_loc.as_posix()}"] f"{wxs_loc.as_posix()}", f"{heat_loc.as_posix()}", f"{manageoldcuradlg_loc.as_posix()}"]
subprocess.call(build_command) subprocess.call(build_command)
link_command = ["light", f"{build_loc.joinpath(wxs_loc.name).with_suffix('.wixobj')}", link_command = ["light", f"{build_loc.joinpath(wxs_loc.name).with_suffix('.wixobj')}",
f"{build_loc.joinpath(heat_loc.name).with_suffix('.wixobj')}", f"{build_loc.joinpath(heat_loc.name).with_suffix('.wixobj')}",
f"{build_loc.joinpath(manageoldcuradlg_loc.name).with_suffix('.wixobj')}", "-ext", "WixUIExtension", f"{build_loc.joinpath(manageoldcuradlg_loc.name).with_suffix('.wixobj')}",
"-ext", "WixUIExtension",
"-ext", "WixFirewallExtension",
"-out", f"{work_loc.joinpath(filename.name)}"] "-out", f"{work_loc.joinpath(filename.name)}"]
subprocess.call(link_command) subprocess.call(link_command)
@ -106,6 +110,6 @@ if __name__ == "__main__":
help="Filename of the exe (e.g. 'UltiMaker-Cura-5.1.0-beta-Windows-X64.msi')") help="Filename of the exe (e.g. 'UltiMaker-Cura-5.1.0-beta-Windows-X64.msi')")
parser.add_argument("name", type=str, help="App name (e.g. 'UltiMaker Cura')") parser.add_argument("name", type=str, help="App name (e.g. 'UltiMaker Cura')")
args = parser.parse_args() args = parser.parse_args()
generate_wxs(args.source_path, args.dist_path, args.filename, args.name) generate_wxs(args.source_path.resolve(), args.dist_path.resolve(), args.filename.resolve(), args.name)
cleanup_artifacts(args.dist_path) cleanup_artifacts(args.dist_path.resolve())
build(args.dist_path, args.filename) build(args.dist_path.resolve(), args.filename)