diff options
| author | Bob Arnson <bob@firegiant.com> | 2020-02-06 22:04:55 -0500 |
|---|---|---|
| committer | Bob Arnson <bob@firegiant.com> | 2020-02-07 22:00:52 -0500 |
| commit | 57559c253fe8ec6f9c66662d11fbcabccc3ba057 (patch) | |
| tree | 60c7b4da6bbb6fe0090498e60fdfbcb769a1af0b /src/WixToolset.Core.WindowsInstaller/Bind/AddCreateFoldersCommand.cs | |
| parent | 9feb0090d2cdd0979bea90ba9aa13dc541f47054 (diff) | |
| download | wix-57559c253fe8ec6f9c66662d11fbcabccc3ba057.tar.gz wix-57559c253fe8ec6f9c66662d11fbcabccc3ba057.tar.bz2 wix-57559c253fe8ec6f9c66662d11fbcabccc3ba057.zip | |
Add CreateFolder tuples for null-keypath components in the backend instead of the compiler.
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/AddCreateFoldersCommand.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/AddCreateFoldersCommand.cs | 40 |
1 files changed, 40 insertions, 0 deletions
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 @@ | |||
| 1 | // 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. | ||
| 2 | |||
| 3 | namespace WixToolset.Core.WindowsInstaller.Bind | ||
| 4 | { | ||
| 5 | using System.Collections.Generic; | ||
| 6 | using System.Linq; | ||
| 7 | using WixToolset.Data; | ||
| 8 | using WixToolset.Data.Tuples; | ||
| 9 | |||
| 10 | /// <summary> | ||
| 11 | /// Add CreateFolder tuples, if not already present, for null-keypath components. | ||
| 12 | /// </summary> | ||
| 13 | internal class AddCreateFoldersCommand | ||
| 14 | { | ||
| 15 | internal AddCreateFoldersCommand(IntermediateSection section) | ||
| 16 | { | ||
| 17 | this.Section = section; | ||
| 18 | } | ||
| 19 | |||
| 20 | private IntermediateSection Section { get; } | ||
| 21 | |||
| 22 | public void Execute() | ||
| 23 | { | ||
| 24 | var createFolderTuplesByComponentRef = new HashSet<string>(this.Section.Tuples.OfType<CreateFolderTuple>().Select(t => t.ComponentRef)); | ||
| 25 | foreach (var componentTuple in this.Section.Tuples.OfType<ComponentTuple>().Where(t => t.KeyPathType == ComponentKeyPathType.Directory).ToList()) | ||
| 26 | { | ||
| 27 | if (!createFolderTuplesByComponentRef.Contains(componentTuple.Id.Id)) | ||
| 28 | { | ||
| 29 | var createFolderTuple = new CreateFolderTuple(componentTuple.SourceLineNumbers) | ||
| 30 | { | ||
| 31 | DirectoryRef = componentTuple.DirectoryRef, | ||
| 32 | ComponentRef = componentTuple.Id.Id, | ||
| 33 | }; | ||
| 34 | |||
| 35 | this.Section.Tuples.Add(createFolderTuple); | ||
| 36 | } | ||
| 37 | } | ||
| 38 | } | ||
| 39 | } | ||
| 40 | } \ No newline at end of file | ||
