From 5fd47421f9565481ca3a94a710b306f6a7be3b9e Mon Sep 17 00:00:00 2001 From: The412Banner <205237651+The412Banner@users.noreply.github.com> Date: Tue, 13 Oct 2026 19:03:38 -0400 Subject: [PATCH] fix: Windows components: .NET Core / Desktop runtimes install again (#740) droiddeck-msi-install: a DuplicateFile entry onto the file itself (dotnet.exe in the .NET host MSI) is skipped like Windows Installer does, instead of stopping the whole install with SameFileError. Fixes .NET Desktop 3/6/7/8, .NET Core 3 and .NET 5. Thanks to whatsupbros for finding and tracing it. --- .../usr/local/bin/droiddeck-msi-install | 9 ++++-- tools/tests/test_msi_install.py | 29 +++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-msi-install b/tools/linuxfs/overlay/usr/local/bin/droiddeck-msi-install index bfa637a7f..c1fe35846 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-msi-install +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-msi-install @@ -601,8 +601,14 @@ class Installer: def put(self, source, rel): target = self.out / rel + # A DuplicateFile row can name the file's own folder and name (the .NET host packages copy + # dotnet.exe onto itself); Windows Installer takes that as nothing to do. Found and diagnosed + # by whatsupbros on the DroidDeck Discord. + if target.exists() and Path(source).samefile(target): + return False target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(source, target) + return True def install_files(self, unpacked): assemblies = self.assemblies() @@ -664,8 +670,7 @@ class Installer: folder = self.directory(row["DestFolder"]) if row.get("DestFolder") else self.files[row["File_"]].rsplit("/", 1)[0] name = long_name(row.get("DestName", "")) or self.files[row["File_"]].rsplit("/", 1)[1] source = self.out / self.files[row["File_"]] - if folder and source.is_file() and "/" not in name: - self.put(source, folder + "/" + name) + if folder and source.is_file() and "/" not in name and self.put(source, folder + "/" + name): self.counts["files"] += 1 if missing: self.notes.append("%d file(s) were not in the package's cabinets" % missing) diff --git a/tools/tests/test_msi_install.py b/tools/tests/test_msi_install.py index 16e8807f1..b896288eb 100644 --- a/tools/tests/test_msi_install.py +++ b/tools/tests/test_msi_install.py @@ -119,6 +119,35 @@ class LayoutTest(unittest.TestCase): inst.select() self.assertEqual(inst.included_components, {"Up", "Wide"}) + def test_a_duplicate_onto_the_file_itself_is_skipped(self): + # The .NET host packages (dotnet-host-*-win-x86.msi) duplicate dotnet.exe into its own + # folder under its own name; copying it onto itself raised SameFileError and stopped every + # .NET Core / Desktop runtime install. + with tempfile.TemporaryDirectory() as tmp: + src = Path(tmp) / "cab" / "dotnet.exe" + src.parent.mkdir() + src.write_bytes(b"MZ") + out = Path(tmp) / "out" + inst = installer({ + "Directory": rows("Directory Directory_Parent DefaultDir", + ("TARGETDIR", "", "SourceDir"), + ("ProgramFilesFolder", "TARGETDIR", "PFiles"), + ("DOTNETHOME", "ProgramFilesFolder", "dotnet"), + ("DOTNETHOME_X86", "ProgramFilesFolder", "dotnet")), + "Component": rows("Component Directory_ Attributes Condition KeyPath", + ("Host", "DOTNETHOME", "0", "", "DotnetExe")), + "Feature": rows("Feature Feature_Parent Level", ("Main", "", "1")), + "FeatureComponents": rows("Feature_ Component_", ("Main", "Host")), + "File": rows("File Component_ FileName", ("DotnetExe", "Host", "dotnet.exe")), + "DuplicateFile": rows("FileKey Component_ File_ DestName DestFolder", + ("Dup", "Host", "DotnetExe", "", "DOTNETHOME_X86")), + }, out=str(out)) + inst.select() + inst.install_files({"DotnetExe": src}) + placed = out / "drive_c/Program Files (x86)/dotnet/dotnet.exe" + self.assertEqual(placed.read_bytes(), b"MZ") + self.assertEqual(inst.counts["files"], 1) + def test_global_assembly_paths(self): with tempfile.TemporaryDirectory() as tmp: dll = Path(tmp) / "a.dll"