diff options
Diffstat (limited to 'src')
10 files changed, 143 insertions, 49 deletions
diff --git a/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs b/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs index 8846cc83..bd282f54 100644 --- a/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs +++ b/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs | |||
| @@ -99,7 +99,7 @@ namespace WixToolset.Core.Burn | |||
| 99 | 99 | ||
| 100 | public IVariableResolver VariableResolver { private get; set; } | 100 | public IVariableResolver VariableResolver { private get; set; } |
| 101 | 101 | ||
| 102 | public IEnumerable<FileTransfer> FileTransfers { get; private set; } | 102 | public IEnumerable<IFileTransfer> FileTransfers { get; private set; } |
| 103 | 103 | ||
| 104 | public IEnumerable<string> ContentFilePaths { get; private set; } | 104 | public IEnumerable<string> ContentFilePaths { get; private set; } |
| 105 | 105 | ||
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index 119cbd55..3aad0709 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs | |||
| @@ -26,6 +26,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 26 | { | 26 | { |
| 27 | this.Messaging = context.ServiceProvider.GetService<IMessaging>(); | 27 | this.Messaging = context.ServiceProvider.GetService<IMessaging>(); |
| 28 | 28 | ||
| 29 | this.BackendHelper = context.ServiceProvider.GetService<IBackendHelper>(); | ||
| 30 | |||
| 29 | this.TableDefinitions = WindowsInstallerStandardInternal.GetTableDefinitions(); | 31 | this.TableDefinitions = WindowsInstallerStandardInternal.GetTableDefinitions(); |
| 30 | 32 | ||
| 31 | this.CabbingThreadCount = context.CabbingThreadCount; | 33 | this.CabbingThreadCount = context.CabbingThreadCount; |
| @@ -43,6 +45,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 43 | this.BackendExtensions = backendExtension; | 45 | this.BackendExtensions = backendExtension; |
| 44 | } | 46 | } |
| 45 | 47 | ||
| 48 | private IMessaging Messaging { get; } | ||
| 49 | |||
| 50 | private IBackendHelper BackendHelper { get; } | ||
| 51 | |||
| 46 | private int Codepage { get; } | 52 | private int Codepage { get; } |
| 47 | 53 | ||
| 48 | private int CabbingThreadCount { get; } | 54 | private int CabbingThreadCount { get; } |
| @@ -63,8 +69,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 63 | 69 | ||
| 64 | private Intermediate Intermediate { get; } | 70 | private Intermediate Intermediate { get; } |
| 65 | 71 | ||
| 66 | private IMessaging Messaging { get; } | ||
| 67 | |||
| 68 | private string OutputPath { get; } | 72 | private string OutputPath { get; } |
| 69 | 73 | ||
| 70 | private bool SuppressAddingValidationRows { get; } | 74 | private bool SuppressAddingValidationRows { get; } |
| @@ -77,7 +81,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 77 | 81 | ||
| 78 | private Validator Validator { get; } | 82 | private Validator Validator { get; } |
| 79 | 83 | ||
| 80 | public IEnumerable<FileTransfer> FileTransfers { get; private set; } | 84 | public IEnumerable<IFileTransfer> FileTransfers { get; private set; } |
| 81 | 85 | ||
| 82 | public IEnumerable<string> ContentFilePaths { get; private set; } | 86 | public IEnumerable<string> ContentFilePaths { get; private set; } |
| 83 | 87 | ||
| @@ -87,7 +91,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 87 | { | 91 | { |
| 88 | var section = this.Intermediate.Sections.Single(); | 92 | var section = this.Intermediate.Sections.Single(); |
| 89 | 93 | ||
| 90 | var fileTransfers = new List<FileTransfer>(); | 94 | var fileTransfers = new List<IFileTransfer>(); |
| 91 | 95 | ||
| 92 | var containsMergeModules = false; | 96 | var containsMergeModules = false; |
| 93 | var suppressedTableNames = new HashSet<string>(); | 97 | var suppressedTableNames = new HashSet<string>(); |
| @@ -375,7 +379,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 375 | { | 379 | { |
| 376 | this.Messaging.Write(VerboseMessages.CreatingCabinetFiles()); | 380 | this.Messaging.Write(VerboseMessages.CreatingCabinetFiles()); |
| 377 | 381 | ||
| 378 | var command = new CreateCabinetsCommand(); | 382 | var command = new CreateCabinetsCommand(this.BackendHelper); |
| 379 | command.CabbingThreadCount = this.CabbingThreadCount; | 383 | command.CabbingThreadCount = this.CabbingThreadCount; |
| 380 | command.CabCachePath = this.CabCachePath; | 384 | command.CabCachePath = this.CabCachePath; |
| 381 | command.DefaultCompressionLevel = this.DefaultCompressionLevel; | 385 | command.DefaultCompressionLevel = this.DefaultCompressionLevel; |
| @@ -415,11 +419,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 415 | string tempDatabaseFile = Path.Combine(this.IntermediateFolder, Path.GetFileName(this.OutputPath)); | 419 | string tempDatabaseFile = Path.Combine(this.IntermediateFolder, Path.GetFileName(this.OutputPath)); |
| 416 | this.GenerateDatabase(output, tempDatabaseFile, false, false); | 420 | this.GenerateDatabase(output, tempDatabaseFile, false, false); |
| 417 | 421 | ||
| 418 | if (FileTransfer.TryCreate(tempDatabaseFile, this.OutputPath, true, output.Type.ToString(), null, out var transfer)) // note where this database needs to move in the future | 422 | var transfer = this.BackendHelper.CreateFileTransfer(tempDatabaseFile, this.OutputPath, true, FileTransferType.Built); // note where this database needs to move in the future |
| 419 | { | 423 | fileTransfers.Add(transfer); |
| 420 | transfer.Built = true; | ||
| 421 | fileTransfers.Add(transfer); | ||
| 422 | } | ||
| 423 | 424 | ||
| 424 | // Stop processing if an error previously occurred. | 425 | // Stop processing if an error previously occurred. |
| 425 | if (this.Messaging.EncounteredError) | 426 | if (this.Messaging.EncounteredError) |
| @@ -491,7 +492,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 491 | // Process uncompressed files. | 492 | // Process uncompressed files. |
| 492 | if (!this.Messaging.EncounteredError && !this.SuppressLayout && uncompressedFiles.Any()) | 493 | if (!this.Messaging.EncounteredError && !this.SuppressLayout && uncompressedFiles.Any()) |
| 493 | { | 494 | { |
| 494 | var command = new ProcessUncompressedFilesCommand(section); | 495 | var command = new ProcessUncompressedFilesCommand(section, this.BackendHelper); |
| 495 | command.Compressed = compressed; | 496 | command.Compressed = compressed; |
| 496 | command.FileFacades = uncompressedFiles; | 497 | command.FileFacades = uncompressedFiles; |
| 497 | command.LayoutDirectory = layoutDirectory; | 498 | command.LayoutDirectory = layoutDirectory; |
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs index 328bb082..ed8f0ece 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs | |||
| @@ -26,19 +26,23 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 26 | public const int DefaultMaximumUncompressedMediaSize = 200; // Default value is 200 MB | 26 | public const int DefaultMaximumUncompressedMediaSize = 200; // Default value is 200 MB |
| 27 | public const int MaxValueOfMaxCabSizeForLargeFileSplitting = 2 * 1024; // 2048 MB (i.e. 2 GB) | 27 | public const int MaxValueOfMaxCabSizeForLargeFileSplitting = 2 * 1024; // 2048 MB (i.e. 2 GB) |
| 28 | 28 | ||
| 29 | private List<FileTransfer> fileTransfers; | 29 | private List<IFileTransfer> fileTransfers; |
| 30 | 30 | ||
| 31 | private FileSplitCabNamesCallback newCabNamesCallBack; | 31 | private FileSplitCabNamesCallback newCabNamesCallBack; |
| 32 | 32 | ||
| 33 | private Dictionary<string, string> lastCabinetAddedToMediaTable; // Key is First Cabinet Name, Value is Last Cabinet Added in the Split Sequence | 33 | private Dictionary<string, string> lastCabinetAddedToMediaTable; // Key is First Cabinet Name, Value is Last Cabinet Added in the Split Sequence |
| 34 | 34 | ||
| 35 | public CreateCabinetsCommand() | 35 | public CreateCabinetsCommand(IBackendHelper backendHelper) |
| 36 | { | 36 | { |
| 37 | this.fileTransfers = new List<FileTransfer>(); | 37 | this.fileTransfers = new List<IFileTransfer>(); |
| 38 | 38 | ||
| 39 | this.newCabNamesCallBack = this.NewCabNamesCallBack; | 39 | this.newCabNamesCallBack = this.NewCabNamesCallBack; |
| 40 | |||
| 41 | this.BackendHelper = backendHelper; | ||
| 40 | } | 42 | } |
| 41 | 43 | ||
| 44 | public IBackendHelper BackendHelper { get; } | ||
| 45 | |||
| 42 | /// <summary> | 46 | /// <summary> |
| 43 | /// Sets the number of threads to use for cabinet creation. | 47 | /// Sets the number of threads to use for cabinet creation. |
| 44 | /// </summary> | 48 | /// </summary> |
| @@ -72,7 +76,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 72 | 76 | ||
| 73 | public IEnumerable<WixMediaTuple> WixMediaTuples { private get; set; } | 77 | public IEnumerable<WixMediaTuple> WixMediaTuples { private get; set; } |
| 74 | 78 | ||
| 75 | public IEnumerable<FileTransfer> FileTransfers => this.fileTransfers; | 79 | public IEnumerable<IFileTransfer> FileTransfers => this.fileTransfers; |
| 76 | 80 | ||
| 77 | /// <param name="output">Output to generate image for.</param> | 81 | /// <param name="output">Output to generate image for.</param> |
| 78 | /// <param name="fileTransfers">Array of files to be transfered.</param> | 82 | /// <param name="fileTransfers">Array of files to be transfered.</param> |
| @@ -186,7 +190,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 186 | /// <param name="fileFacades">Collection of files in this cabinet.</param> | 190 | /// <param name="fileFacades">Collection of files in this cabinet.</param> |
| 187 | /// <param name="fileTransfers">Array of files to be transfered.</param> | 191 | /// <param name="fileTransfers">Array of files to be transfered.</param> |
| 188 | /// <returns>created CabinetWorkItem object</returns> | 192 | /// <returns>created CabinetWorkItem object</returns> |
| 189 | private CabinetWorkItem CreateCabinetWorkItem(Output output, string cabinetDir, MediaTuple mediaRow, CompressionLevel compressionLevel, IEnumerable<FileFacade> fileFacades, List<FileTransfer> fileTransfers) | 193 | private CabinetWorkItem CreateCabinetWorkItem(Output output, string cabinetDir, MediaTuple mediaRow, CompressionLevel compressionLevel, IEnumerable<FileFacade> fileFacades, List<IFileTransfer> fileTransfers) |
| 190 | { | 194 | { |
| 191 | CabinetWorkItem cabinetWorkItem = null; | 195 | CabinetWorkItem cabinetWorkItem = null; |
| 192 | string tempCabinetFileX = Path.Combine(this.TempFilesLocation, mediaRow.Cabinet); | 196 | string tempCabinetFileX = Path.Combine(this.TempFilesLocation, mediaRow.Cabinet); |
| @@ -254,12 +258,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 254 | } | 258 | } |
| 255 | else | 259 | else |
| 256 | { | 260 | { |
| 257 | string destinationPath = Path.Combine(cabinetDir, mediaRow.Cabinet); | 261 | var destinationPath = Path.Combine(cabinetDir, mediaRow.Cabinet); |
| 258 | if (FileTransfer.TryCreate(resolvedCabinet.Path, destinationPath, CabinetBuildOption.BuildAndMove == resolvedCabinet.BuildOption, "Cabinet", mediaRow.SourceLineNumbers, out var transfer)) | 262 | var transfer = this.BackendHelper.CreateFileTransfer(resolvedCabinet.Path, destinationPath, CabinetBuildOption.BuildAndMove == resolvedCabinet.BuildOption, FileTransferType.Built, mediaRow.SourceLineNumbers); |
| 259 | { | 263 | fileTransfers.Add(transfer); |
| 260 | transfer.Built = true; | ||
| 261 | fileTransfers.Add(transfer); | ||
| 262 | } | ||
| 263 | } | 264 | } |
| 264 | 265 | ||
| 265 | return cabinetWorkItem; | 266 | return cabinetWorkItem; |
| @@ -315,21 +316,18 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 315 | bool transferAdded = false; // Used for Error Handling | 316 | bool transferAdded = false; // Used for Error Handling |
| 316 | 317 | ||
| 317 | // Create File Transfer for new Cabinet using transfer of Base Cabinet | 318 | // Create File Transfer for new Cabinet using transfer of Base Cabinet |
| 318 | foreach (FileTransfer transfer in this.FileTransfers) | 319 | foreach (var transfer in this.FileTransfers) |
| 319 | { | 320 | { |
| 320 | if (firstCabinetName.Equals(Path.GetFileName(transfer.Source), StringComparison.InvariantCultureIgnoreCase)) | 321 | if (firstCabinetName.Equals(Path.GetFileName(transfer.Source), StringComparison.InvariantCultureIgnoreCase)) |
| 321 | { | 322 | { |
| 322 | string newCabSourcePath = Path.Combine(Path.GetDirectoryName(transfer.Source), newCabinetName); | 323 | string newCabSourcePath = Path.Combine(Path.GetDirectoryName(transfer.Source), newCabinetName); |
| 323 | string newCabTargetPath = Path.Combine(Path.GetDirectoryName(transfer.Destination), newCabinetName); | 324 | string newCabTargetPath = Path.Combine(Path.GetDirectoryName(transfer.Destination), newCabinetName); |
| 324 | 325 | ||
| 325 | FileTransfer newTransfer; | 326 | var newTransfer = this.BackendHelper.CreateFileTransfer(newCabSourcePath, newCabTargetPath, transfer.Move, FileTransferType.Built, transfer.SourceLineNumbers); |
| 326 | if (FileTransfer.TryCreate(newCabSourcePath, newCabTargetPath, transfer.Move, "Cabinet", transfer.SourceLineNumbers, out newTransfer)) | 327 | this.fileTransfers.Add(newTransfer); |
| 327 | { | 328 | |
| 328 | newTransfer.Built = true; | 329 | transferAdded = true; |
| 329 | this.fileTransfers.Add(newTransfer); | 330 | break; |
| 330 | transferAdded = true; | ||
| 331 | break; | ||
| 332 | } | ||
| 333 | } | 331 | } |
| 334 | } | 332 | } |
| 335 | 333 | ||
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs index 4b143ead..b09f92bb 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs | |||
| @@ -11,6 +11,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 11 | using WixToolset.Data; | 11 | using WixToolset.Data; |
| 12 | using WixToolset.Data.Tuples; | 12 | using WixToolset.Data.Tuples; |
| 13 | using WixToolset.Extensibility.Data; | 13 | using WixToolset.Extensibility.Data; |
| 14 | using WixToolset.Extensibility.Services; | ||
| 14 | using WixToolset.Msi; | 15 | using WixToolset.Msi; |
| 15 | 16 | ||
| 16 | /// <summary> | 17 | /// <summary> |
| @@ -18,13 +19,16 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 18 | /// </summary> | 19 | /// </summary> |
| 19 | internal class ProcessUncompressedFilesCommand | 20 | internal class ProcessUncompressedFilesCommand |
| 20 | { | 21 | { |
| 21 | public ProcessUncompressedFilesCommand(IntermediateSection section) | 22 | public ProcessUncompressedFilesCommand(IntermediateSection section, IBackendHelper backendHelper) |
| 22 | { | 23 | { |
| 23 | this.Section = section; | 24 | this.Section = section; |
| 25 | this.BackendHelper = backendHelper; | ||
| 24 | } | 26 | } |
| 25 | 27 | ||
| 26 | private IntermediateSection Section { get; } | 28 | private IntermediateSection Section { get; } |
| 27 | 29 | ||
| 30 | public IBackendHelper BackendHelper { get; } | ||
| 31 | |||
| 28 | public string DatabasePath { private get; set; } | 32 | public string DatabasePath { private get; set; } |
| 29 | 33 | ||
| 30 | public IEnumerable<FileFacade> FileFacades { private get; set; } | 34 | public IEnumerable<FileFacade> FileFacades { private get; set; } |
| @@ -37,11 +41,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 37 | 41 | ||
| 38 | public Func<MediaTuple, string, string, string> ResolveMedia { private get; set; } | 42 | public Func<MediaTuple, string, string, string> ResolveMedia { private get; set; } |
| 39 | 43 | ||
| 40 | public IEnumerable<FileTransfer> FileTransfers { get; private set; } | 44 | public IEnumerable<IFileTransfer> FileTransfers { get; private set; } |
| 41 | 45 | ||
| 42 | public void Execute() | 46 | public void Execute() |
| 43 | { | 47 | { |
| 44 | var fileTransfers = new List<FileTransfer>(); | 48 | var fileTransfers = new List<IFileTransfer>(); |
| 45 | 49 | ||
| 46 | var directories = new Dictionary<string, ResolvedDirectory>(); | 50 | var directories = new Dictionary<string, ResolvedDirectory>(); |
| 47 | 51 | ||
| @@ -103,11 +107,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 103 | } | 107 | } |
| 104 | 108 | ||
| 105 | // finally put together the base media layout path and the relative file layout path | 109 | // finally put together the base media layout path and the relative file layout path |
| 106 | string fileLayoutPath = Path.Combine(mediaLayoutDirectory, relativeFileLayoutPath); | 110 | var fileLayoutPath = Path.Combine(mediaLayoutDirectory, relativeFileLayoutPath); |
| 107 | if (FileTransfer.TryCreate(facade.WixFile.Source.Path, fileLayoutPath, false, "File", facade.File.SourceLineNumbers, out var transfer)) | 111 | var transfer = this.BackendHelper.CreateFileTransfer(facade.WixFile.Source.Path, fileLayoutPath, false, FileTransferType.Content, facade.File.SourceLineNumbers); |
| 108 | { | 112 | fileTransfers.Add(transfer); |
| 109 | fileTransfers.Add(transfer); | ||
| 110 | } | ||
| 111 | } | 113 | } |
| 112 | } | 114 | } |
| 113 | } | 115 | } |
diff --git a/src/WixToolset.Core/Bind/TransferFilesCommand.cs b/src/WixToolset.Core/Bind/TransferFilesCommand.cs index 79f0cd81..b89d3d03 100644 --- a/src/WixToolset.Core/Bind/TransferFilesCommand.cs +++ b/src/WixToolset.Core/Bind/TransferFilesCommand.cs | |||
| @@ -13,7 +13,7 @@ namespace WixToolset.Core.Bind | |||
| 13 | 13 | ||
| 14 | internal class TransferFilesCommand | 14 | internal class TransferFilesCommand |
| 15 | { | 15 | { |
| 16 | public TransferFilesCommand(IMessaging messaging, IEnumerable<ILayoutExtension> extensions, IEnumerable<FileTransfer> fileTransfers, bool suppressAclReset) | 16 | public TransferFilesCommand(IMessaging messaging, IEnumerable<ILayoutExtension> extensions, IEnumerable<IFileTransfer> fileTransfers, bool suppressAclReset) |
| 17 | { | 17 | { |
| 18 | this.FileSystem = new FileSystem(extensions); | 18 | this.FileSystem = new FileSystem(extensions); |
| 19 | this.Messaging = messaging; | 19 | this.Messaging = messaging; |
| @@ -25,7 +25,7 @@ namespace WixToolset.Core.Bind | |||
| 25 | 25 | ||
| 26 | private IMessaging Messaging { get; } | 26 | private IMessaging Messaging { get; } |
| 27 | 27 | ||
| 28 | private IEnumerable<FileTransfer> FileTransfers { get; } | 28 | private IEnumerable<IFileTransfer> FileTransfers { get; } |
| 29 | 29 | ||
| 30 | private bool SuppressAclReset { get; } | 30 | private bool SuppressAclReset { get; } |
| 31 | 31 | ||
diff --git a/src/WixToolset.Core/ExtensibilityServices/BackendHelper.cs b/src/WixToolset.Core/ExtensibilityServices/BackendHelper.cs new file mode 100644 index 00000000..0e5c4b5b --- /dev/null +++ b/src/WixToolset.Core/ExtensibilityServices/BackendHelper.cs | |||
| @@ -0,0 +1,70 @@ | |||
| 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.ExtensibilityServices | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.IO; | ||
| 7 | using WixToolset.Data; | ||
| 8 | using WixToolset.Extensibility.Data; | ||
| 9 | using WixToolset.Extensibility.Services; | ||
| 10 | |||
| 11 | internal class BackendHelper : IBackendHelper | ||
| 12 | { | ||
| 13 | private static readonly string[] ReservedFileNames = { "CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9" }; | ||
| 14 | |||
| 15 | public BackendHelper(IServiceProvider serviceProvider) | ||
| 16 | { | ||
| 17 | this.Messaging = serviceProvider.GetService<IMessaging>(); | ||
| 18 | } | ||
| 19 | |||
| 20 | private IMessaging Messaging { get; } | ||
| 21 | |||
| 22 | public IFileTransfer CreateFileTransfer(string source, string destination, bool move, FileTransferType type, SourceLineNumber sourceLineNumbers) | ||
| 23 | { | ||
| 24 | var sourceFullPath = GetValidatedFullPath(sourceLineNumbers, source); | ||
| 25 | |||
| 26 | var destinationFullPath = GetValidatedFullPath(sourceLineNumbers, destination); | ||
| 27 | |||
| 28 | return (String.IsNullOrEmpty(sourceFullPath) || String.IsNullOrEmpty(destinationFullPath)) ? null : new FileTransfer | ||
| 29 | { | ||
| 30 | Source = sourceFullPath, | ||
| 31 | Destination = destinationFullPath, | ||
| 32 | Move = move, | ||
| 33 | Type = type, | ||
| 34 | SourceLineNumbers = sourceLineNumbers, | ||
| 35 | Redundant = String.Equals(sourceFullPath, destinationFullPath, StringComparison.OrdinalIgnoreCase) | ||
| 36 | }; | ||
| 37 | } | ||
| 38 | |||
| 39 | private string GetValidatedFullPath(SourceLineNumber sourceLineNumbers, string path) | ||
| 40 | { | ||
| 41 | try | ||
| 42 | { | ||
| 43 | var result = Path.GetFullPath(path); | ||
| 44 | |||
| 45 | var filename = Path.GetFileName(result); | ||
| 46 | |||
| 47 | foreach (var reservedName in ReservedFileNames) | ||
| 48 | { | ||
| 49 | if (reservedName.Equals(filename, StringComparison.OrdinalIgnoreCase)) | ||
| 50 | { | ||
| 51 | this.Messaging.Write(ErrorMessages.InvalidFileName(sourceLineNumbers, path)); | ||
| 52 | return null; | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | return result; | ||
| 57 | } | ||
| 58 | catch (ArgumentException) | ||
| 59 | { | ||
| 60 | this.Messaging.Write(ErrorMessages.InvalidFileName(sourceLineNumbers, path)); | ||
| 61 | } | ||
| 62 | catch (PathTooLongException) | ||
| 63 | { | ||
| 64 | this.Messaging.Write(ErrorMessages.PathTooLong(sourceLineNumbers, path)); | ||
| 65 | } | ||
| 66 | |||
| 67 | return null; | ||
| 68 | } | ||
| 69 | } | ||
| 70 | } | ||
diff --git a/src/WixToolset.Core/FileTransfer.cs b/src/WixToolset.Core/FileTransfer.cs new file mode 100644 index 00000000..9da406eb --- /dev/null +++ b/src/WixToolset.Core/FileTransfer.cs | |||
| @@ -0,0 +1,22 @@ | |||
| 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 | ||
| 4 | { | ||
| 5 | using WixToolset.Data; | ||
| 6 | using WixToolset.Extensibility.Data; | ||
| 7 | |||
| 8 | internal class FileTransfer : IFileTransfer | ||
| 9 | { | ||
| 10 | public string Source { get; set; } | ||
| 11 | |||
| 12 | public string Destination { get; set; } | ||
| 13 | |||
| 14 | public bool Move { get; set; } | ||
| 15 | |||
| 16 | public SourceLineNumber SourceLineNumbers { get; set; } | ||
| 17 | |||
| 18 | public FileTransferType Type { get; set; } | ||
| 19 | |||
| 20 | public bool Redundant { get; set; } | ||
| 21 | } | ||
| 22 | } | ||
diff --git a/src/WixToolset.Core/Layout.cs b/src/WixToolset.Core/Layout.cs index a5e885e5..28c9d5fc 100644 --- a/src/WixToolset.Core/Layout.cs +++ b/src/WixToolset.Core/Layout.cs | |||
| @@ -28,7 +28,7 @@ namespace WixToolset.Core | |||
| 28 | 28 | ||
| 29 | private IMessaging Messaging { get; } | 29 | private IMessaging Messaging { get; } |
| 30 | 30 | ||
| 31 | public IEnumerable<FileTransfer> FileTransfers { get; set; } | 31 | public IEnumerable<IFileTransfer> FileTransfers { get; set; } |
| 32 | 32 | ||
| 33 | public IEnumerable<string> ContentFilePaths { get; set; } | 33 | public IEnumerable<string> ContentFilePaths { get; set; } |
| 34 | 34 | ||
| @@ -124,14 +124,14 @@ namespace WixToolset.Core | |||
| 124 | /// </summary> | 124 | /// </summary> |
| 125 | /// <param name="path">Path to write file.</param> | 125 | /// <param name="path">Path to write file.</param> |
| 126 | /// <param name="fileTransfers">Collection of files that were transferred to the output directory.</param> | 126 | /// <param name="fileTransfers">Collection of files that were transferred to the output directory.</param> |
| 127 | private void CreateOutputsFile(string path, IEnumerable<FileTransfer> fileTransfers) | 127 | private void CreateOutputsFile(string path, IEnumerable<IFileTransfer> fileTransfers) |
| 128 | { | 128 | { |
| 129 | var directory = Path.GetDirectoryName(path); | 129 | var directory = Path.GetDirectoryName(path); |
| 130 | Directory.CreateDirectory(directory); | 130 | Directory.CreateDirectory(directory); |
| 131 | 131 | ||
| 132 | using (var outputs = new StreamWriter(path, false)) | 132 | using (var outputs = new StreamWriter(path, false)) |
| 133 | { | 133 | { |
| 134 | foreach (FileTransfer fileTransfer in fileTransfers) | 134 | foreach (var fileTransfer in fileTransfers) |
| 135 | { | 135 | { |
| 136 | // Don't list files where the source is the same as the destination since | 136 | // Don't list files where the source is the same as the destination since |
| 137 | // that might be the only place the file exists. The outputs file is often | 137 | // that might be the only place the file exists. The outputs file is often |
| @@ -149,18 +149,18 @@ namespace WixToolset.Core | |||
| 149 | /// </summary> | 149 | /// </summary> |
| 150 | /// <param name="path">Path to write file.</param> | 150 | /// <param name="path">Path to write file.</param> |
| 151 | /// <param name="fileTransfers">Collection of files that were transferred to the output directory.</param> | 151 | /// <param name="fileTransfers">Collection of files that were transferred to the output directory.</param> |
| 152 | private void CreateBuiltOutputsFile(string path, IEnumerable<FileTransfer> fileTransfers) | 152 | private void CreateBuiltOutputsFile(string path, IEnumerable<IFileTransfer> fileTransfers) |
| 153 | { | 153 | { |
| 154 | var directory = Path.GetDirectoryName(path); | 154 | var directory = Path.GetDirectoryName(path); |
| 155 | Directory.CreateDirectory(directory); | 155 | Directory.CreateDirectory(directory); |
| 156 | 156 | ||
| 157 | using (var outputs = new StreamWriter(path, false)) | 157 | using (var outputs = new StreamWriter(path, false)) |
| 158 | { | 158 | { |
| 159 | foreach (FileTransfer fileTransfer in fileTransfers) | 159 | foreach (var fileTransfer in fileTransfers) |
| 160 | { | 160 | { |
| 161 | // Only write the built file transfers. Also, skip redundant | 161 | // Only write the built file transfers. Also, skip redundant |
| 162 | // files for the same reason spelled out in this.CreateOutputsFile(). | 162 | // files for the same reason spelled out in this.CreateOutputsFile(). |
| 163 | if (fileTransfer.Built && !fileTransfer.Redundant) | 163 | if (fileTransfer.Type == FileTransferType.Built && !fileTransfer.Redundant) |
| 164 | { | 164 | { |
| 165 | outputs.WriteLine(fileTransfer.Destination); | 165 | outputs.WriteLine(fileTransfer.Destination); |
| 166 | } | 166 | } |
diff --git a/src/WixToolset.Core/LayoutContext.cs b/src/WixToolset.Core/LayoutContext.cs index af0df518..172cea65 100644 --- a/src/WixToolset.Core/LayoutContext.cs +++ b/src/WixToolset.Core/LayoutContext.cs | |||
| @@ -20,7 +20,7 @@ namespace WixToolset.Core | |||
| 20 | 20 | ||
| 21 | public IEnumerable<IFileSystemExtension> FileSystemExtensions { get; set; } | 21 | public IEnumerable<IFileSystemExtension> FileSystemExtensions { get; set; } |
| 22 | 22 | ||
| 23 | public IEnumerable<FileTransfer> FileTransfers { get; set; } | 23 | public IEnumerable<IFileTransfer> FileTransfers { get; set; } |
| 24 | 24 | ||
| 25 | public IEnumerable<string> ContentFilePaths { get; set; } | 25 | public IEnumerable<string> ContentFilePaths { get; set; } |
| 26 | 26 | ||
diff --git a/src/WixToolset.Core/WixToolsetServiceProvider.cs b/src/WixToolset.Core/WixToolsetServiceProvider.cs index dd6da8c8..ffcdbdd1 100644 --- a/src/WixToolset.Core/WixToolsetServiceProvider.cs +++ b/src/WixToolset.Core/WixToolsetServiceProvider.cs | |||
| @@ -22,6 +22,7 @@ namespace WixToolset.Core | |||
| 22 | { typeof(ITupleDefinitionCreator), (provider, singletons) => AddSingleton(singletons, typeof(ITupleDefinitionCreator), new TupleDefinitionCreator(provider)) }, | 22 | { typeof(ITupleDefinitionCreator), (provider, singletons) => AddSingleton(singletons, typeof(ITupleDefinitionCreator), new TupleDefinitionCreator(provider)) }, |
| 23 | { typeof(IParseHelper), (provider, singletons) => AddSingleton(singletons, typeof(IParseHelper), new ParseHelper(provider)) }, | 23 | { typeof(IParseHelper), (provider, singletons) => AddSingleton(singletons, typeof(IParseHelper), new ParseHelper(provider)) }, |
| 24 | { typeof(IPreprocessHelper), (provider, singletons) => AddSingleton(singletons, typeof(IPreprocessHelper), new PreprocessHelper(provider)) }, | 24 | { typeof(IPreprocessHelper), (provider, singletons) => AddSingleton(singletons, typeof(IPreprocessHelper), new PreprocessHelper(provider)) }, |
| 25 | { typeof(IBackendHelper), (provider, singletons) => AddSingleton(singletons, typeof(IBackendHelper), new BackendHelper(provider)) }, | ||
| 25 | { typeof(IWindowsInstallerBackendHelper), (provider, singletons) => AddSingleton(singletons, typeof(IWindowsInstallerBackendHelper), new WindowsInstallerBackendHelper(provider)) }, | 26 | { typeof(IWindowsInstallerBackendHelper), (provider, singletons) => AddSingleton(singletons, typeof(IWindowsInstallerBackendHelper), new WindowsInstallerBackendHelper(provider)) }, |
| 26 | 27 | ||
| 27 | // Transients. | 28 | // Transients. |
