@joebigelow / wix / commits / 9c714a8f

Update to WixOutput file structure to fix embedded file handling

Rob Mensching committed Oct 25, 2019 at 00:48 UTC 9c714a8f1baa6e0130e5cd00cbdca649cebaf6a5
21 files changed +243 -140
src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs
+1 -1
@@ -462,7 +462,7 @@ namespace WixToolset.Core.Burn
462 this.TrackedFiles = trackedFiles;
463
464 // TODO: Eventually this gets removed
465 - var intermediate = new Intermediate(this.Output.Id, new[] { section }, this.Output.Localizations.ToDictionary(l => l.Culture, StringComparer.OrdinalIgnoreCase), this.Output.EmbedFilePaths);
465 + var intermediate = new Intermediate(this.Output.Id, new[] { section }, this.Output.Localizations.ToDictionary(l => l.Culture, StringComparer.OrdinalIgnoreCase));
466 var trackIntermediate = this.BackendHelper.TrackFile(Path.Combine(this.IntermediateFolder, Path.GetFileName(Path.ChangeExtension(this.OutputPath, "wir"))), TrackedFileType.Intermediate);
467 intermediate.Save(trackIntermediate.Path);
468 trackedFiles.Add(trackIntermediate);
src/WixToolset.Core.Burn/Bundles/ProcessPayloadsCommand.cs
+1 -1
@@ -56,7 +56,7 @@ namespace WixToolset.Core.Burn.Bundles
56 // Embedded files (aka: files from binary .wixlibs) are not content files (because they are hidden
57 // in the .wixlib).
58 var sourceFile = payload.SourceFile;
59 - payload.ContentFile = !sourceFile.EmbeddedFileIndex.HasValue;
59 + payload.ContentFile = !sourceFile.Embed;
60
61 this.UpdatePayloadPackagingType(payload);
62
src/WixToolset.Core.TestPackage/WixRunner.cs
+1 -1
@@ -16,7 +16,7 @@ namespace WixToolset.Core.TestPackage
16 return Execute(args, serviceProvider, out messages);
17 }
18
19 - public static WixRunnerResult Execute(string[] args)
19 + public static WixRunnerResult Execute(params string[] args)
20 {
21 var serviceProvider = new WixToolsetServiceProvider();
22 var exitCode = Execute(args, serviceProvider, out var messages);
src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
+51 -15
@@ -17,11 +17,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind
17 /// <summary>
18 /// Binds a databse.
19 /// </summary>
20 - internal class BindDatabaseCommand
20 + internal class BindDatabaseCommand : IDisposable
21 {
22 // As outlined in RFC 4122, this is our namespace for generating name-based (version 3) UUIDs.
23 internal static readonly Guid WixComponentGuidNamespace = new Guid("{3064E5C6-FB63-4FE9-AC49-E446A792EFA5}");
24
25 + private bool disposed;
26 +
27 public BindDatabaseCommand(IBindContext context, IEnumerable<IWindowsInstallerBackendBinderExtension> backendExtension, Validator validator)
28 {
29 this.ServiceProvider = context.ServiceProvider;
@@ -92,7 +94,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
94
95 public IEnumerable<ITrackedFile> TrackedFiles { get; private set; }
96
95 - public Pdb Pdb { get; private set; }
97 + public WixOutput Wixout { get; private set; }
98
99 public void Execute()
100 {
@@ -524,29 +526,41 @@ namespace WixToolset.Core.WindowsInstaller.Bind
526 trackedFiles.AddRange(command.TrackedFiles);
527 }
528
527 - this.Pdb = new Pdb { Output = output };
528 -
529 - if (!String.IsNullOrEmpty(this.OutputPdbPath))
530 - {
531 - var trackPdb = this.BackendHelper.TrackFile(this.OutputPdbPath, TrackedFileType.Final);
532 - trackedFiles.Add(trackPdb);
533 -
534 - this.Pdb.Save(trackPdb.Path);
535 - }
529 + this.Wixout = this.CreateWixout(trackedFiles, this.Intermediate, output);
530
531 this.FileTransfers = fileTransfers;
532 // TODO: this is not sufficient to collect all Input files (for example, it misses Binary and Icon tables).
539 - trackedFiles.AddRange(fileFacades.Select(f => this.BackendHelper.TrackFile(f.File.Source.Path, TrackedFileType.Input, f.File.SourceLineNumbers)));
533 + trackedFiles.AddRange(fileFacades.Select(f => this.BackendHelper.TrackFile(f.File.Source.Path, TrackedFileType.Input, f.File.SourceLineNumbers)));
534 this.TrackedFiles = trackedFiles;
535
536 // TODO: Eventually this gets removed
543 - var intermediate = new Intermediate(this.Intermediate.Id, new[] { section }, this.Intermediate.Localizations.ToDictionary(l => l.Culture, StringComparer.OrdinalIgnoreCase), this.Intermediate.EmbedFilePaths);
537 + var intermediate = new Intermediate(this.Intermediate.Id, new[] { section }, this.Intermediate.Localizations.ToDictionary(l => l.Culture, StringComparer.OrdinalIgnoreCase));
538 var trackIntermediate = this.BackendHelper.TrackFile(Path.Combine(this.IntermediateFolder, Path.GetFileName(Path.ChangeExtension(this.OutputPath, "wir"))), TrackedFileType.Intermediate);
539 intermediate.Save(trackIntermediate.Path);
540 trackedFiles.Add(trackIntermediate);
541 + }
542
548 - //transfer = this.BackendHelper.CreateFileTransfer(intermediatePath, Path.ChangeExtension(this.OutputPath, "wir"), true, FileTransferType.Built);
549 - //fileTransfers.Add(transfer);
543 + private WixOutput CreateWixout(List<ITrackedFile> trackedFiles, Intermediate intermediate, Output output)
544 + {
545 + WixOutput wixout;
546 +
547 + if (String.IsNullOrEmpty(this.OutputPdbPath))
548 + {
549 + wixout = WixOutput.Create();
550 + }
551 + else
552 + {
553 + var trackPdb = this.BackendHelper.TrackFile(this.OutputPdbPath, TrackedFileType.Final);
554 + trackedFiles.Add(trackPdb);
555 +
556 + wixout = WixOutput.Create(trackPdb.Path);
557 + }
558 +
559 + intermediate.Save(wixout);
560 +
561 + output.Save(wixout);
562 +
563 + return wixout;
564 }
565
566 #if TODO_FINISH_PATCH
@@ -934,5 +948,27 @@ namespace WixToolset.Core.WindowsInstaller.Bind
948
949 return command.GeneratedTemporaryFiles;
950 }
951 +
952 + #region IDisposable Support
953 +
954 + public void Dispose()
955 + {
956 + this.Dispose(true);
957 + }
958 +
959 + protected virtual void Dispose(bool disposing)
960 + {
961 + if (!this.disposed)
962 + {
963 + if (disposing)
964 + {
965 + this.Wixout?.Dispose();
966 + }
967 +
968 + this.disposed = true;
969 + }
970 + }
971 +
972 + #endregion
973 }
974 }
src/WixToolset.Core.WindowsInstaller/MsiBackend.cs
+12 -10
@@ -2,7 +2,6 @@
2
3 namespace WixToolset.Core.WindowsInstaller
4 {
5 - using System;
5 using WixToolset.Core.WindowsInstaller.Bind;
6 using WixToolset.Core.WindowsInstaller.Inscribe;
7 using WixToolset.Core.WindowsInstaller.Unbind;
@@ -26,18 +25,21 @@ namespace WixToolset.Core.WindowsInstaller
25
26 var validator = Validator.CreateFromContext(context, "darice.cub");
27
29 - var command = new BindDatabaseCommand(context, backendExtensions, validator);
30 - command.Execute();
28 + using (var command = new BindDatabaseCommand(context, backendExtensions, validator))
29 + {
30 + command.Execute();
31
32 - var result = context.ServiceProvider.GetService<IBindResult>();
33 - result.FileTransfers = command.FileTransfers;
34 - result.TrackedFiles = command.TrackedFiles;
32 + var result = context.ServiceProvider.GetService<IBindResult>();
33 + result.FileTransfers = command.FileTransfers;
34 + result.TrackedFiles = command.TrackedFiles;
35
36 - foreach (var extension in backendExtensions)
37 - {
38 - extension.PostBackendBind(result, command.Pdb);
36 + foreach (var extension in backendExtensions)
37 + {
38 + extension.PostBackendBind(result, command.Wixout);
39 + }
40 +
41 + return result;
42 }
40 - return result;
43 }
44
45 public IDecompileResult Decompile(IDecompileContext context)
src/WixToolset.Core.WindowsInstaller/MsmBackend.cs
+12 -19
@@ -2,7 +2,6 @@
2
3 namespace WixToolset.Core.WindowsInstaller
4 {
5 - using System;
5 using WixToolset.Core.WindowsInstaller.Bind;
6 using WixToolset.Core.WindowsInstaller.Unbind;
7 using WixToolset.Data;
@@ -25,24 +24,21 @@ namespace WixToolset.Core.WindowsInstaller
24
25 var validator = Validator.CreateFromContext(context, "mergemod.cub");
26
28 - var command = new BindDatabaseCommand(context, backendExtensions, validator);
29 - command.Execute();
27 + using (var command = new BindDatabaseCommand(context, backendExtensions, validator))
28 + {
29 + command.Execute();
30
31 - var result = context.ServiceProvider.GetService<IBindResult>();
32 - result.FileTransfers = command.FileTransfers;
33 - result.TrackedFiles = command.TrackedFiles;
31 + var result = context.ServiceProvider.GetService<IBindResult>();
32 + result.FileTransfers = command.FileTransfers;
33 + result.TrackedFiles = command.TrackedFiles;
34
35 - foreach (var extension in backendExtensions)
36 - {
37 - extension.PostBackendBind(result, command.Pdb);
38 - }
35 + foreach (var extension in backendExtensions)
36 + {
37 + extension.PostBackendBind(result, command.Wixout);
38 + }
39
40 - if (!String.IsNullOrEmpty(context.OutputPdbPath))
41 - {
42 - command.Pdb?.Save(context.OutputPdbPath);
40 + return result;
41 }
44 -
45 - return result;
42 }
43
44 public IDecompileResult Decompile(IDecompileContext context)
@@ -67,10 +63,7 @@ namespace WixToolset.Core.WindowsInstaller
63 return result;
64 }
65
70 - public bool Inscribe(IInscribeContext context)
71 - {
72 - return false;
73 - }
66 + public bool Inscribe(IInscribeContext context) => false;
67
68 public Intermediate Unbind(IUnbindContext context)
69 {
src/WixToolset.Core/Bind/ExpectedExtractFile.cs
+2 -2
@@ -1,4 +1,4 @@
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.
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.Bind
4 {
@@ -9,7 +9,7 @@ namespace WixToolset.Core.Bind
9 {
10 public Uri Uri { get; set; }
11
12 - public int EmbeddedFileIndex { get; set; }
12 + public string EmbeddedFileId { get; set; }
13
14 public string OutputPath { get; set; }
15 }
src/WixToolset.Core/Bind/ExtractEmbeddedFiles.cs
+21 -17
@@ -15,7 +15,7 @@ namespace WixToolset.Core.Bind
15 /// </summary>
16 internal class ExtractEmbeddedFiles
17 {
18 - private Dictionary<Uri, SortedList<int, string>> filesWithEmbeddedFiles = new Dictionary<Uri, SortedList<int, string>>();
18 + private readonly Dictionary<Uri, SortedList<string, string>> filesWithEmbeddedFiles = new Dictionary<Uri, SortedList<string, string>>();
19
20 public IEnumerable<Uri> Uris => this.filesWithEmbeddedFiles.Keys;
21
@@ -23,28 +23,28 @@ namespace WixToolset.Core.Bind
23 /// Adds an embedded file index to track and returns the path where the embedded file will be extracted. Duplicates will return the same extract path.
24 /// </summary>
25 /// <param name="uri">Uri to file containing the embedded files.</param>
26 - /// <param name="embeddedFileIndex">Index of the embedded file to extract.</param>
27 - /// <param name="tempPath">Path where temporary files should be placed.</param>
26 + /// <param name="embeddedFileId">Id of the embedded file to extract.</param>
27 + /// <param name="extractFolder">Folder where extracted files should be placed.</param>
28 /// <returns>The extract path for the embedded file.</returns>
29 - public string AddEmbeddedFileIndex(Uri uri, int embeddedFileIndex, string tempPath)
29 + public string AddEmbeddedFileToExtract(Uri uri, string embeddedFileId, string extractFolder)
30 {
31 // If the uri to the file that contains the embedded file does not already have embedded files
32 // being extracted, create the dictionary to track that.
33 if (!this.filesWithEmbeddedFiles.TryGetValue(uri, out var extracts))
34 {
35 - extracts = new SortedList<int, string>();
35 + extracts = new SortedList<string, string>(StringComparer.OrdinalIgnoreCase);
36 this.filesWithEmbeddedFiles.Add(uri, extracts);
37 }
38
39 // If the embedded file is not already tracked in the dictionary of extracts, add it.
40 - if (!extracts.TryGetValue(embeddedFileIndex, out var extractPath))
40 + if (!extracts.TryGetValue(embeddedFileId, out var extractPath))
41 {
42 - string localFileNameWithoutExtension = Path.GetFileNameWithoutExtension(uri.LocalPath);
43 - string unique = this.HashUri(uri.AbsoluteUri);
44 - string extractedName = String.Format(CultureInfo.InvariantCulture, @"{0}_{1}\{2}", localFileNameWithoutExtension, unique, embeddedFileIndex);
42 + var localFileNameWithoutExtension = Path.GetFileNameWithoutExtension(uri.LocalPath);
43 + var unique = this.HashUri(uri.AbsoluteUri);
44 + var extractedName = String.Format(CultureInfo.InvariantCulture, @"{0}_{1}\{2}", localFileNameWithoutExtension, unique, embeddedFileId);
45
46 - extractPath = Path.Combine(tempPath, extractedName);
47 - extracts.Add(embeddedFileIndex, extractPath);
46 + extractPath = Path.GetFullPath(Path.Combine(extractFolder, extractedName));
47 + extracts.Add(embeddedFileId, extractPath);
48 }
49
50 return extractPath;
@@ -52,35 +52,39 @@ namespace WixToolset.Core.Bind
52
53 public IEnumerable<ExpectedExtractFile> GetExpectedEmbeddedFiles()
54 {
55 + var files = new List<ExpectedExtractFile>();
56 +
57 foreach (var uriWithExtracts in this.filesWithEmbeddedFiles)
58 {
59 foreach (var extracts in uriWithExtracts.Value)
60 {
59 - yield return new ExpectedExtractFile
61 + files.Add(new ExpectedExtractFile
62 {
63 Uri = uriWithExtracts.Key,
62 - EmbeddedFileIndex = extracts.Key,
64 + EmbeddedFileId = extracts.Key,
65 OutputPath = extracts.Value,
64 - };
66 + });
67 }
68 }
69 +
70 + return files;
71 }
72
73 public IEnumerable<ExpectedExtractFile> GetExtractFilesForUri(Uri uri)
74 {
75 if (!this.filesWithEmbeddedFiles.TryGetValue(uri, out var extracts))
76 {
73 - extracts = new SortedList<int, string>();
77 + extracts = new SortedList<string, string>(StringComparer.OrdinalIgnoreCase);
78 }
79
76 - return extracts.Select(e => new ExpectedExtractFile() { Uri = uri, EmbeddedFileIndex = e.Key, OutputPath = e.Value });
80 + return extracts.Select(e => new ExpectedExtractFile { Uri = uri, EmbeddedFileId = e.Key, OutputPath = e.Value });
81 }
82
83 private string HashUri(string uri)
84 {
85 using (SHA1 sha1 = new SHA1CryptoServiceProvider())
86 {
83 - byte[] hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(uri));
87 + var hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(uri));
88 return Convert.ToBase64String(hash).TrimEnd('=').Replace('+', '-').Replace('/', '_');
89 }
90 }
src/WixToolset.Core/Bind/ExtractEmbeddedFilesCommand.cs
+6 -30
@@ -2,10 +2,9 @@
2
3 namespace WixToolset.Core.Bind
4 {
5 + using System;
6 using System.Collections.Generic;
6 - using System.IO;
7 using System.Linq;
8 - using System.Reflection;
8 using WixToolset.Data;
9 using WixToolset.Extensibility.Data;
10
@@ -26,41 +25,18 @@ namespace WixToolset.Core.Bind
25 {
26 var baseUri = expectedEmbeddedFileByUri.Key;
27
29 - Stream stream = null;
30 - try
28 + using (var wixout = WixOutput.Read(baseUri))
29 {
32 - // If the embedded files are stored in an assembly resource stream (usually
33 - // a .wixlib embedded in a WixExtension).
34 - if ("embeddedresource" == baseUri.Scheme)
35 - {
36 - var assemblyPath = Path.GetFullPath(baseUri.LocalPath);
37 - var resourceName = baseUri.Fragment.TrimStart('#');
38 -
39 - var assembly = Assembly.LoadFile(assemblyPath);
40 - stream = assembly.GetManifestResourceStream(resourceName);
41 - }
42 - else // normal file (usually a binary .wixlib on disk).
43 - {
44 - stream = File.OpenRead(baseUri.LocalPath);
45 - }
30 + var uniqueIds = new SortedSet<string>(StringComparer.OrdinalIgnoreCase);
31
47 - using (var fs = FileStructure.Read(stream))
32 + foreach (var embeddedFile in expectedEmbeddedFileByUri)
33 {
49 - var uniqueIndicies = new SortedSet<int>();
50 -
51 - foreach (var embeddedFile in expectedEmbeddedFileByUri)
34 + if (uniqueIds.Add(embeddedFile.EmbeddedFileId))
35 {
53 - if (uniqueIndicies.Add(embeddedFile.EmbeddedFileIndex))
54 - {
55 - fs.ExtractEmbeddedFile(embeddedFile.EmbeddedFileIndex, embeddedFile.OutputPath);
56 - }
36 + wixout.ExtractEmbeddedFile(embeddedFile.EmbeddedFileId, embeddedFile.OutputPath);
37 }
38 }
39 }
60 - finally
61 - {
62 - stream?.Close();
63 - }
40 }
41 }
42 }
src/WixToolset.Core/Bind/ResolveFieldsCommand.cs
+2 -2
@@ -98,9 +98,9 @@ namespace WixToolset.Core.Bind
98 #endif
99
100 // File is embedded and path to it was not modified above.
101 - if (objectField.EmbeddedFileIndex.HasValue && isDefault)
101 + if (isDefault && objectField.Embed)
102 {
103 - var extractPath = this.FilesWithEmbeddedFiles.AddEmbeddedFileIndex(objectField.BaseUri, objectField.EmbeddedFileIndex.Value, this.IntermediateFolder);
103 + var extractPath = this.FilesWithEmbeddedFiles.AddEmbeddedFileToExtract(objectField.BaseUri, objectField.Path, this.IntermediateFolder);
104
105 // Set the path to the embedded file once where it will be extracted.
106 field.Set(extractPath);
src/WixToolset.Core/CommandLine/BuildCommand.cs
+24 -14
@@ -100,29 +100,38 @@ namespace WixToolset.Core.CommandLine
100
101 if (this.OutputType == OutputType.Library)
102 {
103 - var wixlib = this.LibraryPhase(wixobjs, wxls, this.commandLine.BindFiles, this.commandLine.BindPaths);
104 -
105 - if (!this.Messaging.EncounteredError)
103 + using (new IntermediateFieldContext("wix.lib"))
104 {
107 - wixlib.Save(this.commandLine.OutputFile);
105 + var wixlib = this.LibraryPhase(wixobjs, wxls, this.commandLine.BindFiles, this.commandLine.BindPaths);
106 +
107 + if (!this.Messaging.EncounteredError)
108 + {
109 + wixlib.Save(this.commandLine.OutputFile);
110 + }
111 }
112 }
113 else
114 {
112 - if (wixipl == null)
113 - {
114 - wixipl = this.LinkPhase(wixobjs, this.commandLine.LibraryFilePaths, creator);
115 - }
116 -
117 - if (!this.Messaging.EncounteredError)
115 + using (new IntermediateFieldContext("wix.link"))
116 {
119 - if (this.OutputType == OutputType.IntermediatePostLink)
117 + if (wixipl == null)
118 {
121 - wixipl.Save(this.commandLine.OutputFile);
119 + wixipl = this.LinkPhase(wixobjs, this.commandLine.LibraryFilePaths, creator);
120 }
123 - else
121 +
122 + if (!this.Messaging.EncounteredError)
123 {
125 - this.BindPhase(wixipl, wxls, filterCultures, this.commandLine.CabCachePath, this.commandLine.BindPaths, this.commandLine.BurnStubPath);
124 + if (this.OutputType == OutputType.IntermediatePostLink)
125 + {
126 + wixipl.Save(this.commandLine.OutputFile);
127 + }
128 + else
129 + {
130 + using (new IntermediateFieldContext("wix.bind"))
131 + {
132 + this.BindPhase(wixipl, wxls, filterCultures, this.commandLine.CabCachePath, this.commandLine.BindPaths, this.commandLine.BurnStubPath);
133 + }
134 + }
135 }
136 }
137 }
@@ -469,6 +478,7 @@ namespace WixToolset.Core.CommandLine
478 break;
479 }
480
481 + case "bf":
482 case "bindfiles":
483 this.BindFiles = true;
484 return true;
src/WixToolset.Core/Librarian.cs
+4 -10
@@ -56,14 +56,14 @@ namespace WixToolset.Core
56 return null;
57 }
58
59 - var embedFilePaths = this.ResolveFilePathsToEmbed(context, sections);
59 + this.ResolveFilePathsToEmbed(context, sections);
60
61 foreach (var section in sections)
62 {
63 section.LibraryId = context.LibraryId;
64 }
65
66 - library = new Intermediate(context.LibraryId, sections, localizationsByCulture, embedFilePaths);
66 + library = new Intermediate(context.LibraryId, sections, localizationsByCulture);
67
68 this.Validate(library);
69 }
@@ -78,10 +78,8 @@ namespace WixToolset.Core
78 return this.Messaging.EncounteredError ? null : library;
79 }
80
81 - private List<string> ResolveFilePathsToEmbed(ILibraryContext context, IEnumerable<IntermediateSection> sections)
81 + private void ResolveFilePathsToEmbed(ILibraryContext context, IEnumerable<IntermediateSection> sections)
82 {
83 - var embedFilePaths = new List<string>();
84 -
83 // Resolve paths to files that are to be embedded in the library.
84 if (context.BindFiles)
85 {
@@ -104,9 +102,7 @@ namespace WixToolset.Core
102 if (!String.IsNullOrEmpty(file))
103 {
104 // File was successfully resolved so track the embedded index as the embedded file index.
107 - field.Set(new IntermediateFieldPathValue { EmbeddedFileIndex = embedFilePaths.Count });
108 -
109 - embedFilePaths.Add(file);
105 + field.Set(new IntermediateFieldPathValue { Embed = true, Path = file });
106 }
107 else
108 {
@@ -116,8 +112,6 @@ namespace WixToolset.Core
112 }
113 }
114 }
119 -
120 - return embedFilePaths;
115 }
116
117 private void Validate(Intermediate library)
src/WixToolset.Core/Linker.cs
+1 -1
@@ -564,7 +564,7 @@ namespace WixToolset.Core
564 var collate = new CollateLocalizationsCommand(this.Messaging, localizations);
565 var localizationsByCulture = collate.Execute();
566
567 - intermediate = new Intermediate(resolvedSection.Id, new[] { resolvedSection }, localizationsByCulture, null);
567 + intermediate = new Intermediate(resolvedSection.Id, new[] { resolvedSection }, localizationsByCulture);
568
569 #if MOVE_TO_BACKEND
570 this.CheckOutputConsistency(output);
src/test/Example.Extension/Data/example.wir
Binary files a/src/test/Example.Extension/Data/example.wir and b/src/test/Example.Extension/Data/example.wir differ
src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs
+76 -11
@@ -312,9 +312,8 @@ namespace WixToolsetTest.CoreIntegration
312 var pdbPath = Path.Combine(intermediateFolder, @"bin\test.wixpdb");
313 Assert.True(File.Exists(pdbPath));
314
315 - var pdb = Pdb.Load(pdbPath, suppressVersionCheck: true);
316 - Assert.NotNull(pdb);
317 - Assert.NotNull(pdb.Output);
315 + var output = Output.Load(pdbPath, suppressVersionCheck: true);
316 + Assert.NotNull(output);
317 }
318 }
319
@@ -448,6 +447,74 @@ namespace WixToolsetTest.CoreIntegration
447 }
448 }
449
450 + [Fact]
451 + public void CanBuildBinaryWixlib()
452 + {
453 + var folder = TestData.Get(@"TestData\SingleFile");
454 +
455 + using (var fs = new DisposableFileSystem())
456 + {
457 + var baseFolder = fs.GetFolder();
458 + var intermediateFolder = Path.Combine(baseFolder, "obj");
459 +
460 + var result = WixRunner.Execute(
461 + "build",
462 + Path.Combine(folder, "Package.wxs"),
463 + Path.Combine(folder, "PackageComponents.wxs"),
464 + "-loc", Path.Combine(folder, "Package.en-us.wxl"),
465 + "-bindpath", Path.Combine(folder, "data"),
466 + "-intermediateFolder", intermediateFolder,
467 + "-bindfiles",
468 + "-o", Path.Combine(baseFolder, @"bin\test.wixlib"));
469 +
470 + result.AssertSuccess();
471 +
472 + using (var wixout = WixOutput.Read(Path.Combine(baseFolder, @"bin\test.wixlib")))
473 + {
474 + Assert.NotNull(wixout.GetDataStream("wix-ir.json"));
475 +
476 + var text = wixout.GetData("wix-ir/test.txt");
477 + Assert.Equal("This is test.txt.", text);
478 + }
479 + }
480 + }
481 +
482 + [Fact]
483 + public void CanBuildBinaryWixlibWithCollidingFilenames()
484 + {
485 + var folder = TestData.Get(@"TestData\SameFileFolders");
486 +
487 + using (var fs = new DisposableFileSystem())
488 + {
489 + var baseFolder = fs.GetFolder();
490 + var intermediateFolder = Path.Combine(baseFolder, "obj");
491 +
492 + var result = WixRunner.Execute(
493 + "build",
494 + Path.Combine(folder, "TestComponents.wxs"),
495 + "-bindpath", Path.Combine(folder, "data"),
496 + "-intermediateFolder", intermediateFolder,
497 + "-bindfiles",
498 + "-o", Path.Combine(baseFolder, @"bin\test.wixlib"));
499 +
500 + result.AssertSuccess();
501 +
502 + using (var wixout = WixOutput.Read(Path.Combine(baseFolder, @"bin\test.wixlib")))
503 + {
504 + Assert.NotNull(wixout.GetDataStream("wix-ir.json"));
505 +
506 + var text = wixout.GetData("wix-ir/test.txt");
507 + Assert.Equal(@"This is a\test.txt.", text);
508 +
509 + var text2 = wixout.GetData("wix-ir/test.txt-1");
510 + Assert.Equal(@"This is b\test.txt.", text2);
511 +
512 + var text3 = wixout.GetData("wix-ir/test.txt-2");
513 + Assert.Equal(@"This is c\test.txt.", text3);
514 + }
515 + }
516 + }
517 +
518 [Fact]
519 public void CanBuildWithIncludePath()
520 {
@@ -459,8 +526,7 @@ namespace WixToolsetTest.CoreIntegration
526 var baseFolder = fs.GetFolder();
527 var intermediateFolder = Path.Combine(baseFolder, "obj");
528
462 - var result = WixRunner.Execute(new[]
463 - {
529 + var result = WixRunner.Execute(
530 "build",
531 Path.Combine(folder, "Package.wxs"),
532 Path.Combine(folder, "PackageComponents.wxs"),
@@ -468,8 +534,7 @@ namespace WixToolsetTest.CoreIntegration
534 "-bindpath", bindpath,
535 "-intermediateFolder", intermediateFolder,
536 "-o", Path.Combine(baseFolder, @"bin\test.msi"),
471 - "-i", bindpath,
472 - });
537 + "-i", bindpath);
538
539 result.AssertSuccess();
540
@@ -635,8 +700,8 @@ namespace WixToolsetTest.CoreIntegration
700
701 result.AssertSuccess();
702
638 - var pdb = Pdb.Load(Path.Combine(baseFolder, @"bin\test.wixpdb"), false);
639 - var caRows = pdb.Output.Tables["CustomAction"].Rows.Single();
703 + var output = Output.Load(Path.Combine(baseFolder, @"bin\test.wixpdb"), false);
704 + var caRows = output.Tables["CustomAction"].Rows.Single();
705 Assert.Equal("SetINSTALLLOCATION", caRows.FieldAsString(0));
706 Assert.Equal("51", caRows.FieldAsString(1));
707 Assert.Equal("INSTALLLOCATION", caRows.FieldAsString(2));
@@ -711,8 +776,8 @@ namespace WixToolsetTest.CoreIntegration
776
777 result.AssertSuccess();
778
714 - var pdb = Pdb.Load(Path.Combine(intermediateFolder, @"bin\test.wixpdb"), false);
715 - Assert.NotEmpty(pdb.Output.SubStorages);
779 + var output = Output.Load(Path.Combine(intermediateFolder, @"bin\test.wixpdb"), false);
780 + Assert.NotEmpty(output.SubStorages);
781 }
782 }
783 }
src/test/WixToolsetTest.CoreIntegration/TestData/SameFileFolders/TestComponents.wxs new
+16
@@ -0,0 +1,16 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 + <Fragment>
4 + <ComponentGroup Id="ProductComponents">
5 + <Component Directory="INSTALLFOLDER:\a">
6 + <File Source="a\test.txt" />
7 + </Component>
8 + <Component Directory="INSTALLFOLDER:\b">
9 + <File Source="b\test.txt" />
10 + </Component>
11 + <Component Directory="INSTALLFOLDER:\c">
12 + <File Source="c\test.txt" />
13 + </Component>
14 + </ComponentGroup>
15 + </Fragment>
16 +</Wix>
src/test/WixToolsetTest.CoreIntegration/TestData/SameFileFolders/data/a/test.txt new
+1
@@ -0,0 +1 @@
1 +This is a\test.txt.
\ No newline at end of file
src/test/WixToolsetTest.CoreIntegration/TestData/SameFileFolders/data/b/test.txt new
+1
@@ -0,0 +1 @@
1 +This is b\test.txt.
\ No newline at end of file
src/test/WixToolsetTest.CoreIntegration/TestData/SameFileFolders/data/c/test.txt new
+1
@@ -0,0 +1 @@
1 +This is c\test.txt.
\ No newline at end of file
src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
+4
@@ -36,6 +36,10 @@
36 <Content Include="TestData\Font\FontTitle.wxs" CopyToOutputDirectory="PreserveNewest" />
37 <Content Include="TestData\Icon\SampleIcon.wxs" CopyToOutputDirectory="PreserveNewest" />
38 <Content Include="TestData\LockPermissions\EmptyPermissions.wxs" CopyToOutputDirectory="PreserveNewest" />
39 + <Content Include="TestData\SameFileFolders\data\a\test.txt" CopyToOutputDirectory="PreserveNewest" />
40 + <Content Include="TestData\SameFileFolders\data\c\test.txt" CopyToOutputDirectory="PreserveNewest" />
41 + <Content Include="TestData\SameFileFolders\data\b\test.txt" CopyToOutputDirectory="PreserveNewest" />
42 + <Content Include="TestData\SameFileFolders\TestComponents.wxs" CopyToOutputDirectory="PreserveNewest" />
43 <Content Include="TestData\ProductWithComponentGroupRef\MinimalComponentGroup.wxs" CopyToOutputDirectory="PreserveNewest" />
44 <Content Include="TestData\ProductWithComponentGroupRef\Product.wxs" CopyToOutputDirectory="PreserveNewest" />
45 <Content Include="TestData\Registry\RegistryValue.wxs" CopyToOutputDirectory="PreserveNewest" />
src/test/WixToolsetTest.CoreIntegration/WixiplFixture.cs
+6 -6
@@ -128,14 +128,14 @@ namespace WixToolsetTest.CoreIntegration
128 {
129 var binary = section.Tuples.OfType<BinaryTuple>().Single();
130 var path = binary[BinaryTupleFields.Data].AsPath().Path;
131 - Assert.Contains("Example.Extension", path);
132 - Assert.EndsWith(@"\0", path);
131 + Assert.StartsWith(Path.Combine(baseFolder, @"obj\Example.Extension"), path);
132 + Assert.EndsWith(@"wix-ir\example.txt", path);
133 Assert.Equal(@"BinFromWir", binary.Id.Id);
134 }
135 }
136 }
137
138 - [Fact(Skip = "Test demonstrates failure")]
138 + [Fact]
139 public void CanBuildWixiplUsingExtensionLibrary()
140 {
141 var folder = TestData.Get(@"TestData\Wixipl");
@@ -171,7 +171,7 @@ namespace WixToolsetTest.CoreIntegration
171
172 result.AssertSuccess();
173
174 - var intermediate = Intermediate.Load(Path.Combine(baseFolder, @"obj\test.wir"));
174 + var intermediate = Intermediate.Load(Path.Combine(baseFolder, @"bin\test.wixpdb"));
175 var section = intermediate.Sections.Single();
176
177 {
@@ -183,8 +183,8 @@ namespace WixToolsetTest.CoreIntegration
183 {
184 var binary = section.Tuples.OfType<BinaryTuple>().Single();
185 var path = binary[BinaryTupleFields.Data].AsPath().Path;
186 - Assert.Contains("Example.Extension", path);
187 - Assert.EndsWith(@"\0", path);
186 + Assert.StartsWith(Path.Combine(baseFolder, @"obj\test"), path);
187 + Assert.EndsWith(@"wix-ir\example.txt", path);
188 Assert.Equal(@"BinFromWir", binary.Id.Id);
189 }
190 }