/// <summary> /// Creates a new empty output object. /// </summary> internal Output() { this.componentsToFeatures = new ConnectToFeatureCollection(); this.modulesToFeatures = new ConnectToFeatureCollection(); this.featuresToFeatures = new ConnectToFeatureCollection(); this.ignoreModularizations = new IgnoreModularizationCollection(); this.outputTables = new OutputTableCollection(); this.importStreams = new ImportStreamCollection(); this.modules = new RowCollection(); this.fileMediaInfoCollection = new FileMediaInformationCollection(); this.mediaRows = new MediaRowCollection(); this.suppressAdminSequence = false; this.suppressAdvertiseSequence = false; this.suppressUISequence = false; }
/// <summary> /// Creates a cabinet using the wixcab.dll interop layer. /// </summary> /// <param name="cabinetDir">Directory to create cabinet in.</param> /// <param name="cabinetName">Name of cabinet to create.</param> /// <param name="level">Level of compression to compress with.</param> /// <param name="files">Array of files to put into cabinet.</param> /// <param name="importStreams">Collection of import streams to add cabinet to if embedding.</param> /// <param name="fileTransfers">Array of files to be transfered.</param> private void CreateCabinet(string cabinetDir, string cabinetName, CompressionLevel level, ArrayList files, ImportStreamCollection importStreams, ArrayList fileTransfers) { if (0 == files.Count || this.foundError) { return; } bool embedCabinet; string cabinetPath; string[] fileIds = new string[files.Count]; string[] filePaths = new string[files.Count]; // if the cabinet is embedded if (cabinetName.StartsWith("#")) { cabinetName = cabinetName.Substring(1); cabinetPath = Path.Combine(this.tempFiles.BasePath, cabinetName); embedCabinet = true; } else // cabinet is not embedded { cabinetPath = Path.Combine(this.tempFiles.BasePath, cabinetName); embedCabinet = false; } for (int i = 0; i < files.Count; i++) { FileMediaInformation fmi = (FileMediaInformation)files[i]; fileIds[i] = fmi.File; try { filePaths[i] = this.extension.FileResolutionHandler(fmi.Source, FileResolutionType.File); } catch (WixFileNotFoundException wfnfe) { this.OnMessage(WixErrors.BinderExtensionMissingFile(null, ErrorLevel.Normal, wfnfe.Message)); continue; } this.OnMessage(WixVerboses.CabFile(null, VerboseLevel.Verbose, fileIds[i], filePaths[i])); } if (this.foundError) { // Don't create the cabinet if errors have been found. return; } CabinetBuildOption cabinetBuildOption = this.extension.CabinetResolutionHandler(fileIds, filePaths, ref cabinetPath); // build the cabinet if its not being skipped if (CabinetBuildOption.BuildAndCopy == cabinetBuildOption || CabinetBuildOption.BuildAndMove == cabinetBuildOption) { WixCreateCab cab = null; try { cab = new WixCreateCab(Path.GetFileName(cabinetPath), Path.GetDirectoryName(cabinetPath), 0, 0, level); cab.AddFiles(filePaths, fileIds, false); } catch (WixCabCreationException wcce) { if (null != wcce.FileName) { this.OnMessage(WixErrors.CabCreationFailed(cabinetPath, wcce.FileName, wcce.ErrorCode)); } else { this.OnMessage(WixErrors.CabCreationFailed(cabinetPath, wcce.ErrorCode)); } } catch (FileNotFoundException fnfe) { throw new WixFileNotFoundException(null, fnfe.FileName, fnfe); } finally { if (null != cab) { try { cab.Close(); } catch (WixCabCreationException) { this.OnMessage(WixErrors.CabClosureFailed(cabinetPath)); } } } } if (embedCabinet) { importStreams.Add(new ImportStream(ImportStreamType.Cabinet, cabinetName, cabinetPath)); } else { string destinationPath = Path.Combine(cabinetDir, cabinetName); fileTransfers.Add(new FileTransfer(cabinetPath, destinationPath, CabinetBuildOption.BuildAndMove == cabinetBuildOption)); } }