From 57559c253fe8ec6f9c66662d11fbcabccc3ba057 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Thu, 6 Feb 2020 22:04:55 -0500 Subject: Add CreateFolder tuples for null-keypath components in the backend instead of the compiler. --- .../Bind/AddCreateFoldersCommand.cs | 40 ++++++++++++++++++++++ .../Bind/BindDatabaseCommand.cs | 6 ++++ 2 files changed, 46 insertions(+) create mode 100644 src/WixToolset.Core.WindowsInstaller/Bind/AddCreateFoldersCommand.cs (limited to 'src/WixToolset.Core.WindowsInstaller') diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/AddCreateFoldersCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/AddCreateFoldersCommand.cs new file mode 100644 index 00000000..6cc4153f --- /dev/null +++ b/src/WixToolset.Core.WindowsInstaller/Bind/AddCreateFoldersCommand.cs @@ -0,0 +1,40 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Core.WindowsInstaller.Bind +{ + using System.Collections.Generic; + using System.Linq; + using WixToolset.Data; + using WixToolset.Data.Tuples; + + /// + /// Add CreateFolder tuples, if not already present, for null-keypath components. + /// + internal class AddCreateFoldersCommand + { + internal AddCreateFoldersCommand(IntermediateSection section) + { + this.Section = section; + } + + private IntermediateSection Section { get; } + + public void Execute() + { + var createFolderTuplesByComponentRef = new HashSet(this.Section.Tuples.OfType().Select(t => t.ComponentRef)); + foreach (var componentTuple in this.Section.Tuples.OfType().Where(t => t.KeyPathType == ComponentKeyPathType.Directory).ToList()) + { + if (!createFolderTuplesByComponentRef.Contains(componentTuple.Id.Id)) + { + var createFolderTuple = new CreateFolderTuple(componentTuple.SourceLineNumbers) + { + DirectoryRef = componentTuple.DirectoryRef, + ComponentRef = componentTuple.Id.Id, + }; + + this.Section.Tuples.Add(createFolderTuple); + } + } + } + } +} \ No newline at end of file diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index 34104ef5..1bcaf209 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs @@ -338,6 +338,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind command.Execute(); } + // Add missing CreateFolder tuples to null-keypath components. + { + var command = new AddCreateFoldersCommand(section); + command.Execute(); + } + // stop processing if an error previously occurred if (this.Messaging.EncounteredError) { -- cgit v1.2.3-55-g6feb