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 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/WixToolset.Core.WindowsInstaller/Bind/AddCreateFoldersCommand.cs (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/AddCreateFoldersCommand.cs') 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 -- cgit v1.2.3-55-g6feb