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.
This commit is contained in:
The412Banner authored and GitHub committed 2026-10-13 19:03:38 -04:00
1 parent 93352da1d0
commit 5fd47421f9
2 files changed
+36 -2

No files matched your search

@@ -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)
+29
View File
@@ -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"