aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.WindowsInstaller
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2019-10-07 11:18:13 -0700
committerRob Mensching <rob@firegiant.com>2019-10-07 11:59:14 -0700
commit860676fa5b40a1904478151e9b4934c004e7db63 (patch)
tree83fabd53f2a68dcf56bc8da66d88e115af3764b0 /src/WixToolset.Core.WindowsInstaller
parent3b98dac62b47d590f3465985362d6e6fd100b1c0 (diff)
downloadwix-860676fa5b40a1904478151e9b4934c004e7db63.tar.gz
wix-860676fa5b40a1904478151e9b4934c004e7db63.tar.bz2
wix-860676fa5b40a1904478151e9b4934c004e7db63.zip
Implement Bundle build
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller')
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs8
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs16
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs1
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs16
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/PathResolver.cs106
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs13
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/ResolvedDirectory.cs31
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs1
8 files changed, 41 insertions, 151 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
index 830880ee..53451752 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
@@ -30,6 +30,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind
30 30
31 this.BackendHelper = context.ServiceProvider.GetService<IBackendHelper>(); 31 this.BackendHelper = context.ServiceProvider.GetService<IBackendHelper>();
32 32
33 this.PathResolver = this.ServiceProvider.GetService<IPathResolver>();
34
33 this.TableDefinitions = WindowsInstallerStandardInternal.GetTableDefinitions(); 35 this.TableDefinitions = WindowsInstallerStandardInternal.GetTableDefinitions();
34 36
35 this.CabbingThreadCount = context.CabbingThreadCount; 37 this.CabbingThreadCount = context.CabbingThreadCount;
@@ -54,6 +56,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind
54 56
55 private IBackendHelper BackendHelper { get; } 57 private IBackendHelper BackendHelper { get; }
56 58
59 private IPathResolver PathResolver { get; }
60
57 private int Codepage { get; } 61 private int Codepage { get; }
58 62
59 private int CabbingThreadCount { get; } 63 private int CabbingThreadCount { get; }
@@ -241,7 +245,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
241 245
242 // Set generated component guids. 246 // Set generated component guids.
243 { 247 {
244 var command = new CalculateComponentGuids(this.Messaging, this.BackendHelper, section); 248 var command = new CalculateComponentGuids(this.Messaging, this.BackendHelper, this.PathResolver, section);
245 command.Execute(); 249 command.Execute();
246 } 250 }
247 251
@@ -501,7 +505,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
501 // Process uncompressed files. 505 // Process uncompressed files.
502 if (!this.Messaging.EncounteredError && !this.SuppressLayout && uncompressedFiles.Any()) 506 if (!this.Messaging.EncounteredError && !this.SuppressLayout && uncompressedFiles.Any())
503 { 507 {
504 var command = new ProcessUncompressedFilesCommand(section, this.BackendHelper); 508 var command = new ProcessUncompressedFilesCommand(section, this.BackendHelper, this.PathResolver);
505 command.Compressed = compressed; 509 command.Compressed = compressed;
506 command.FileFacades = uncompressedFiles; 510 command.FileFacades = uncompressedFiles;
507 command.LayoutDirectory = layoutDirectory; 511 command.LayoutDirectory = layoutDirectory;
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs
index 835d9b8d..8135ae2e 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs
@@ -6,9 +6,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind
6 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using System.IO; 7 using System.IO;
8 using System.Linq; 8 using System.Linq;
9 using WixToolset.Core.Native;
10 using WixToolset.Data; 9 using WixToolset.Data;
11 using WixToolset.Data.Tuples; 10 using WixToolset.Data.Tuples;
11 using WixToolset.Extensibility.Data;
12 using WixToolset.Extensibility.Services; 12 using WixToolset.Extensibility.Services;
13 13
14 /// <summary> 14 /// <summary>
@@ -16,10 +16,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind
16 /// </summary> 16 /// </summary>
17 internal class CalculateComponentGuids 17 internal class CalculateComponentGuids
18 { 18 {
19 internal CalculateComponentGuids(IMessaging messaging, IBackendHelper helper, IntermediateSection section) 19 internal CalculateComponentGuids(IMessaging messaging, IBackendHelper helper, IPathResolver pathResolver, IntermediateSection section)
20 { 20 {
21 this.Messaging = messaging; 21 this.Messaging = messaging;
22 this.BackendHelper = helper; 22 this.BackendHelper = helper;
23 this.PathResolver = pathResolver;
23 this.Section = section; 24 this.Section = section;
24 } 25 }
25 26
@@ -27,12 +28,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind
27 28
28 private IBackendHelper BackendHelper { get; } 29 private IBackendHelper BackendHelper { get; }
29 30
31 private IPathResolver PathResolver { get; }
32
30 private IntermediateSection Section { get; } 33 private IntermediateSection Section { get; }
31 34
32 public void Execute() 35 public void Execute()
33 { 36 {
34 Dictionary<string, RegistryTuple> registryKeyRows = null; 37 Dictionary<string, RegistryTuple> registryKeyRows = null;
35 Dictionary<string, ResolvedDirectory> targetPathsByDirectoryId = null; 38 Dictionary<string, IResolvedDirectory> targetPathsByDirectoryId = null;
36 Dictionary<string, string> componentIdGenSeeds = null; 39 Dictionary<string, string> componentIdGenSeeds = null;
37 Dictionary<string, List<FileTuple>> filesByComponentId = null; 40 Dictionary<string, List<FileTuple>> filesByComponentId = null;
38 41
@@ -73,7 +76,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
73 { 76 {
74 var directories = this.Section.Tuples.OfType<DirectoryTuple>().ToList(); 77 var directories = this.Section.Tuples.OfType<DirectoryTuple>().ToList();
75 78
76 targetPathsByDirectoryId = new Dictionary<string, ResolvedDirectory>(directories.Count); 79 targetPathsByDirectoryId = new Dictionary<string, IResolvedDirectory>(directories.Count);
77 80
78 // Get the target paths for all directories. 81 // Get the target paths for all directories.
79 foreach (var directory in directories) 82 foreach (var directory in directories)
@@ -86,7 +89,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind
86 continue; 89 continue;
87 } 90 }
88 91
89 targetPathsByDirectoryId.Add(directory.Id.Id, new ResolvedDirectory(directory.ParentDirectoryRef, directory.Name)); 92 var resolvedDirectory = this.BackendHelper.CreateResolvedDirectory(directory.ParentDirectoryRef, directory.Name);
93 targetPathsByDirectoryId.Add(directory.Id.Id, resolvedDirectory);
90 } 94 }
91 } 95 }
92 96
@@ -131,7 +135,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
131 if (fileRow.Id.Id == componentTuple.KeyPath) 135 if (fileRow.Id.Id == componentTuple.KeyPath)
132 { 136 {
133 // calculate the key file's canonical target path 137 // calculate the key file's canonical target path
134 string directoryPath = PathResolver.GetDirectoryPath(targetPathsByDirectoryId, componentIdGenSeeds, componentTuple.DirectoryRef, true); 138 string directoryPath = this.PathResolver.GetDirectoryPath(targetPathsByDirectoryId, componentIdGenSeeds, componentTuple.DirectoryRef, true);
135 string fileName = Common.GetName(fileRow.Name, false, true).ToLowerInvariant(); 139 string fileName = Common.GetName(fileRow.Name, false, true).ToLowerInvariant();
136 path = Path.Combine(directoryPath, fileName); 140 path = Path.Combine(directoryPath, fileName);
137 141
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs
index 95438f96..a9b0f5f5 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs
@@ -8,7 +8,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind
8 using System.IO; 8 using System.IO;
9 using System.Linq; 9 using System.Linq;
10 using System.Runtime.InteropServices; 10 using System.Runtime.InteropServices;
11 using System.Threading;
12 using WixToolset.Core.Bind; 11 using WixToolset.Core.Bind;
13 using WixToolset.Data; 12 using WixToolset.Data;
14 using WixToolset.Data.Tuples; 13 using WixToolset.Data.Tuples;
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs
index f76cd227..cd3a67fa 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs
@@ -105,6 +105,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind
105 this.AddMsiEmbeddedUITuple((MsiEmbeddedUITuple)tuple, output); 105 this.AddMsiEmbeddedUITuple((MsiEmbeddedUITuple)tuple, output);
106 break; 106 break;
107 107
108 case TupleDefinitionType.MsiFileHash:
109 this.AddMsiFileHashTuple((MsiFileHashTuple)tuple, output);
110 break;
111
108 case TupleDefinitionType.MsiServiceConfig: 112 case TupleDefinitionType.MsiServiceConfig:
109 this.AddMsiServiceConfigTuple((MsiServiceConfigTuple)tuple, output); 113 this.AddMsiServiceConfigTuple((MsiServiceConfigTuple)tuple, output);
110 break; 114 break;
@@ -500,6 +504,18 @@ namespace WixToolset.Core.WindowsInstaller.Bind
500 row[4] = tuple.Source; 504 row[4] = tuple.Source;
501 } 505 }
502 506
507 private void AddMsiFileHashTuple(MsiFileHashTuple tuple, Output output)
508 {
509 var table = output.EnsureTable(this.TableDefinitions["MsiFileHash"]);
510 var row = table.CreateRow(tuple.SourceLineNumbers);
511 row[0] = tuple.Id.Id;
512 row[1] = tuple.Options;
513 row[2] = tuple.HashPart1;
514 row[3] = tuple.HashPart2;
515 row[4] = tuple.HashPart3;
516 row[5] = tuple.HashPart4;
517 }
518
503 private void AddMsiServiceConfigTuple(MsiServiceConfigTuple tuple, Output output) 519 private void AddMsiServiceConfigTuple(MsiServiceConfigTuple tuple, Output output)
504 { 520 {
505 var events = tuple.OnInstall ? WindowsInstallerConstants.MsidbServiceConfigEventInstall : 0; 521 var events = tuple.OnInstall ? WindowsInstallerConstants.MsidbServiceConfigEventInstall : 0;
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/PathResolver.cs b/src/WixToolset.Core.WindowsInstaller/Bind/PathResolver.cs
deleted file mode 100644
index 6dc18271..00000000
--- a/src/WixToolset.Core.WindowsInstaller/Bind/PathResolver.cs
+++ /dev/null
@@ -1,106 +0,0 @@
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
3namespace WixToolset.Core.WindowsInstaller.Bind
4{
5 using System;
6 using System.Collections.Generic;
7 using System.IO;
8 using WixToolset.Data;
9 using WixToolset.Data.WindowsInstaller;
10
11 internal static class PathResolver
12 {
13 /// <summary>
14 /// Get the source path of a directory.
15 /// </summary>
16 /// <param name="directories">All cached directories.</param>
17 /// <param name="componentIdGenSeeds">Hash table of Component GUID generation seeds indexed by directory id.</param>
18 /// <param name="directory">Directory identifier.</param>
19 /// <param name="canonicalize">Canonicalize the path for standard directories.</param>
20 /// <returns>Source path of a directory.</returns>
21 public static string GetDirectoryPath(Dictionary<string, ResolvedDirectory> directories, Dictionary<string, string> componentIdGenSeeds, string directory, bool canonicalize)
22 {
23 if (!directories.TryGetValue(directory, out var resolvedDirectory))
24 {
25 throw new WixException(ErrorMessages.ExpectedDirectory(directory));
26 }
27
28 if (null == resolvedDirectory.Path)
29 {
30 if (null != componentIdGenSeeds && componentIdGenSeeds.ContainsKey(directory))
31 {
32 resolvedDirectory.Path = componentIdGenSeeds[directory];
33 }
34 else if (canonicalize && WindowsInstallerStandard.IsStandardDirectory(directory))
35 {
36 // when canonicalization is on, standard directories are treated equally
37 resolvedDirectory.Path = directory;
38 }
39 else
40 {
41 string name = resolvedDirectory.Name;
42
43 if (canonicalize)
44 {
45 name = name?.ToLowerInvariant();
46 }
47
48 if (String.IsNullOrEmpty(resolvedDirectory.DirectoryParent))
49 {
50 resolvedDirectory.Path = name;
51 }
52 else
53 {
54 string parentPath = GetDirectoryPath(directories, componentIdGenSeeds, resolvedDirectory.DirectoryParent, canonicalize);
55
56 if (null != resolvedDirectory.Name)
57 {
58 resolvedDirectory.Path = Path.Combine(parentPath, name);
59 }
60 else
61 {
62 resolvedDirectory.Path = parentPath;
63 }
64 }
65 }
66 }
67
68 return resolvedDirectory.Path;
69 }
70
71 /// <summary>
72 /// Gets the source path of a file.
73 /// </summary>
74 /// <param name="directories">All cached directories in <see cref="ResolvedDirectory"/>.</param>
75 /// <param name="directoryId">Parent directory identifier.</param>
76 /// <param name="fileName">File name (in long|source format).</param>
77 /// <param name="compressed">Specifies the package is compressed.</param>
78 /// <param name="useLongName">Specifies the package uses long file names.</param>
79 /// <returns>Source path of file relative to package directory.</returns>
80 public static string GetFileSourcePath(Dictionary<string, ResolvedDirectory> directories, string directoryId, string fileName, bool compressed, bool useLongName)
81 {
82 string fileSourcePath = Common.GetName(fileName, true, useLongName);
83
84 if (compressed)
85 {
86 // Use just the file name of the file since all uncompressed files must appear
87 // in the root of the image in a compressed package.
88 }
89 else
90 {
91 // Get the relative path of where we want the file to be layed out as specified
92 // in the Directory table.
93 string directoryPath = PathResolver.GetDirectoryPath(directories, null, directoryId, false);
94 fileSourcePath = Path.Combine(directoryPath, fileSourcePath);
95 }
96
97 // Strip off "SourceDir" if it's still on there.
98 if (fileSourcePath.StartsWith("SourceDir\\", StringComparison.Ordinal))
99 {
100 fileSourcePath = fileSourcePath.Substring(10);
101 }
102
103 return fileSourcePath;
104 }
105 }
106}
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs
index 61e82f68..64fb3e4d 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs
@@ -18,16 +18,19 @@ namespace WixToolset.Core.WindowsInstaller.Bind
18 /// </summary> 18 /// </summary>
19 internal class ProcessUncompressedFilesCommand 19 internal class ProcessUncompressedFilesCommand
20 { 20 {
21 public ProcessUncompressedFilesCommand(IntermediateSection section, IBackendHelper backendHelper) 21 public ProcessUncompressedFilesCommand(IntermediateSection section, IBackendHelper backendHelper, IPathResolver pathResolver)
22 { 22 {
23 this.Section = section; 23 this.Section = section;
24 this.BackendHelper = backendHelper; 24 this.BackendHelper = backendHelper;
25 this.PathResolver = pathResolver;
25 } 26 }
26 27
27 private IntermediateSection Section { get; } 28 private IntermediateSection Section { get; }
28 29
29 public IBackendHelper BackendHelper { get; } 30 public IBackendHelper BackendHelper { get; }
30 31
32 public IPathResolver PathResolver { get; }
33
31 public string DatabasePath { private get; set; } 34 public string DatabasePath { private get; set; }
32 35
33 public IEnumerable<FileFacade> FileFacades { private get; set; } 36 public IEnumerable<FileFacade> FileFacades { private get; set; }
@@ -50,7 +53,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
50 53
51 var trackedFiles = new List<ITrackedFile>(); 54 var trackedFiles = new List<ITrackedFile>();
52 55
53 var directories = new Dictionary<string, ResolvedDirectory>(); 56 var directories = new Dictionary<string, IResolvedDirectory>();
54 57
55 var mediaRows = this.Section.Tuples.OfType<MediaTuple>().ToDictionary(t => t.DiskId); 58 var mediaRows = this.Section.Tuples.OfType<MediaTuple>().ToDictionary(t => t.DiskId);
56 59
@@ -69,7 +72,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind
69 72
70 string sourceName = Common.GetName(directoryRecord.GetString(3), true, this.LongNamesInImage); 73 string sourceName = Common.GetName(directoryRecord.GetString(3), true, this.LongNamesInImage);
71 74
72 directories.Add(directoryRecord.GetString(1), new ResolvedDirectory(directoryRecord.GetString(2), sourceName)); 75 var resolvedDirectory = this.BackendHelper.CreateResolvedDirectory(directoryRecord.GetString(2), sourceName);
76
77 directories.Add(directoryRecord.GetString(1), resolvedDirectory);
73 } 78 }
74 } 79 }
75 } 80 }
@@ -99,7 +104,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
99 throw new WixException(ErrorMessages.FileIdentifierNotFound(facade.File.SourceLineNumbers, facade.File.Id.Id)); 104 throw new WixException(ErrorMessages.FileIdentifierNotFound(facade.File.SourceLineNumbers, facade.File.Id.Id));
100 } 105 }
101 106
102 relativeFileLayoutPath = PathResolver.GetFileSourcePath(directories, fileRecord[1], fileRecord[2], this.Compressed, this.LongNamesInImage); 107 relativeFileLayoutPath = this.PathResolver.GetFileSourcePath(directories, fileRecord[1], fileRecord[2], this.Compressed, this.LongNamesInImage);
103 } 108 }
104 109
105 // finally put together the base media layout path and the relative file layout path 110 // finally put together the base media layout path and the relative file layout path
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ResolvedDirectory.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ResolvedDirectory.cs
deleted file mode 100644
index e06321cf..00000000
--- a/src/WixToolset.Core.WindowsInstaller/Bind/ResolvedDirectory.cs
+++ /dev/null
@@ -1,31 +0,0 @@
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
3namespace WixToolset.Core.WindowsInstaller.Bind
4{
5 /// <summary>
6 /// Structure used for resolved directory information.
7 /// </summary>
8 internal struct ResolvedDirectory
9 {
10 /// <summary>
11 /// Constructor for ResolvedDirectory.
12 /// </summary>
13 /// <param name="directoryParent">Parent directory.</param>
14 /// <param name="name">The directory name.</param>
15 public ResolvedDirectory(string directoryParent, string name)
16 {
17 this.DirectoryParent = directoryParent;
18 this.Name = name;
19 this.Path = null;
20 }
21
22 /// <summary>The directory parent.</summary>
23 public string DirectoryParent { get; set; }
24
25 /// <summary>The name of this directory.</summary>
26 public string Name { get; set; }
27
28 /// <summary>The path of this directory.</summary>
29 public string Path { get; set; }
30 }
31}
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs
index 397092c4..1f2a22d9 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs
@@ -162,7 +162,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind
162 this.Section.Tuples.Add(facade.Hash); 162 this.Section.Tuples.Add(facade.Hash);
163 } 163 }
164 164
165 facade.Hash.FileRef = facade.File.Id.Id;
166 facade.Hash.Options = 0; 165 facade.Hash.Options = 0;
167 facade.Hash.HashPart1 = hash[0]; 166 facade.Hash.HashPart1 = hash[0];
168 facade.Hash.HashPart2 = hash[1]; 167 facade.Hash.HashPart2 = hash[1];