public void Execute() { var bundleFilename = Path.GetFileName(this.OutputPath); // Copy the burn.exe to a writable location then mark it to be moved to its final build location. var stubPlatform = this.BundleSymbol.Platform.ToString(); var stubFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), stubPlatform, "burn.exe"); if (stubPlatform != "X86") { this.Messaging.Write(WarningMessages.ExperimentalBundlePlatform(stubPlatform)); } var bundleTempPath = Path.Combine(this.IntermediateFolder, bundleFilename); this.Messaging.Write(VerboseMessages.GeneratingBundle(bundleTempPath, stubFile)); if ("setup.exe".Equals(bundleFilename, StringComparison.OrdinalIgnoreCase)) { this.Messaging.Write(ErrorMessages.InsecureBundleFilename(bundleFilename)); } this.Transfer = this.BackendHelper.CreateFileTransfer(bundleTempPath, this.OutputPath, true, this.BundleSymbol.SourceLineNumbers); File.Copy(stubFile, bundleTempPath, true); File.SetAttributes(bundleTempPath, FileAttributes.Normal); var windowsAssemblyVersion = GetWindowsAssemblyVersion(this.BundleSymbol); var applicationManifestData = GenerateApplicationManifest(this.BundleSymbol, this.BootstrapperApplicationDllSymbol, this.OutputPath, windowsAssemblyVersion); UpdateBurnResources(bundleTempPath, this.OutputPath, this.BundleSymbol, windowsAssemblyVersion, applicationManifestData); // Update the .wixburn section to point to at the UX and attached container(s) then attach the containers // if they should be attached. using (var writer = BurnWriter.Open(this.Messaging, bundleTempPath)) { var burnStubFile = new FileInfo(bundleTempPath); writer.InitializeBundleSectionData(burnStubFile.Length, this.BundleSymbol.BundleId); // Always attach the UX container first writer.AppendContainer(this.UXContainer.WorkingPath, BurnWriter.Container.UX); // Now append all other attached containers foreach (var container in this.Containers) { if (ContainerType.Attached == container.Type) { // The container was only created if it had payloads. if (!String.IsNullOrEmpty(container.WorkingPath) && BurnConstants.BurnUXContainerName != container.Id.Id) { writer.AppendContainer(container.WorkingPath, BurnWriter.Container.Attached); } } } } }
/// <summary> /// Opens a Burn writer. /// </summary> /// <param name="messaging"></param> /// <param name="fileExe">Path to file.</param> /// <returns>Burn writer.</returns> public static BurnWriter Open(IMessaging messaging, string fileExe) { BurnWriter writer = new BurnWriter(messaging, fileExe); using (BinaryReader binaryReader = new BinaryReader(File.Open(fileExe, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete))) { if (!writer.Initialize(binaryReader)) { writer.invalidBundle = true; } } if (!writer.invalidBundle) { writer.binaryWriter = new BinaryWriter(File.Open(fileExe, FileMode.Open, FileAccess.ReadWrite, FileShare.Read | FileShare.Delete)); } return(writer); }