public void DetectAttachedContainerCollisions()
        {
            var attachedContainerPayloadsByNameByContainer = new Dictionary <string, Dictionary <string, WixBundlePayloadSymbol> >();

            foreach (var payload in this.PayloadSymbols.Values.Where(p => p.Packaging == PackagingType.Embedded))
            {
                var containerId = payload.ContainerRef;
                var container   = this.Containers[containerId];
                if (container.Type == ContainerType.Attached)
                {
                    if (!attachedContainerPayloadsByNameByContainer.TryGetValue(containerId, out var attachedContainerPayloadsByName))
                    {
                        attachedContainerPayloadsByName = new Dictionary <string, WixBundlePayloadSymbol>(StringComparer.OrdinalIgnoreCase);
                        attachedContainerPayloadsByNameByContainer.Add(containerId, attachedContainerPayloadsByName);
                    }

                    if (!attachedContainerPayloadsByName.TryGetValue(payload.Name, out var collisionPayload))
                    {
                        attachedContainerPayloadsByName.Add(payload.Name, payload);
                    }
                    else
                    {
                        if (containerId == BurnConstants.BurnUXContainerName)
                        {
                            this.Messaging.Write(BurnBackendErrors.BAContainerPayloadCollision(payload.SourceLineNumbers, payload.Id.Id, payload.Name));
                            this.Messaging.Write(BurnBackendErrors.BAContainerPayloadCollision2(collisionPayload.SourceLineNumbers));
                        }
                        else
                        {
                            this.Messaging.Write(BurnBackendWarnings.AttachedContainerPayloadCollision(payload.SourceLineNumbers, payload.Id.Id, payload.Name));
                            this.Messaging.Write(BurnBackendWarnings.AttachedContainerPayloadCollision2(collisionPayload.SourceLineNumbers));
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public void Execute()
        {
            var fileTransfers    = new List <IFileTransfer>();
            var trackedFiles     = new List <ITrackedFile>();
            var uxPayloadSymbols = new List <WixBundlePayloadSymbol>();

            var attachedContainerIndex = 1; // count starts at one because UX container is "0".

            var payloadsByContainer = this.PayloadSymbols.Values.ToLookup(p => p.ContainerRef);

            foreach (var container in this.Containers)
            {
                var containerId = container.Id.Id;

                var containerPayloads = payloadsByContainer[containerId];

                if (!containerPayloads.Any())
                {
                    if (containerId != BurnConstants.BurnDefaultAttachedContainerName)
                    {
                        this.Messaging.Write(BurnBackendWarnings.EmptyContainer(container.SourceLineNumbers, containerId));
                    }
                }
                else if (BurnConstants.BurnUXContainerName == containerId)
                {
                    this.UXContainer = container;

                    container.WorkingPath            = Path.Combine(this.IntermediateFolder, container.Name);
                    container.AttachedContainerIndex = 0;

                    // Gather the list of UX payloads but ensure the BootstrapperApplicationDll Payload is the first
                    // in the list since that is the Payload that Burn attempts to load.
                    var baPayloadId = this.BootstrapperApplicationDllSymbol.Id.Id;

                    foreach (var uxPayload in containerPayloads)
                    {
                        if (uxPayload.Id.Id == baPayloadId)
                        {
                            uxPayloadSymbols.Insert(0, uxPayload);
                        }
                        else
                        {
                            uxPayloadSymbols.Add(uxPayload);
                        }
                    }
                }
                else
                {
                    container.WorkingPath = Path.Combine(this.IntermediateFolder, container.Name);

                    // Add detached containers to the list of file transfers.
                    if (ContainerType.Detached == container.Type)
                    {
                        var transfer = this.BackendHelper.CreateFileTransfer(container.WorkingPath, Path.Combine(this.LayoutFolder, container.Name), true, container.SourceLineNumbers);
                        fileTransfers.Add(transfer);
                    }
                    else // update the attached container index.
                    {
                        Debug.Assert(ContainerType.Attached == container.Type);

                        container.AttachedContainerIndex = attachedContainerIndex;
                        ++attachedContainerIndex;
                    }
                }
            }

            foreach (var container in this.Containers.Where(c => !String.IsNullOrEmpty(c.WorkingPath) && c.Id.Id != BurnConstants.BurnUXContainerName))
            {
                if (container.Type == ContainerType.Attached && attachedContainerIndex > 2 && container.Id.Id != BurnConstants.BurnDefaultAttachedContainerName)
                {
                    this.Messaging.Write(BurnBackendErrors.MultipleAttachedContainersUnsupported(container.SourceLineNumbers, container.Id.Id));
                }
            }

            if (!this.Messaging.EncounteredError)
            {
                foreach (var container in this.Containers.Where(c => !String.IsNullOrEmpty(c.WorkingPath) && c.Id.Id != BurnConstants.BurnUXContainerName))
                {
                    this.CreateContainer(container, payloadsByContainer[container.Id.Id]);
                    trackedFiles.Add(this.BackendHelper.TrackFile(container.WorkingPath, TrackedFileType.Temporary, container.SourceLineNumbers));
                }
            }

            this.UXContainerPayloads = uxPayloadSymbols;
            this.FileTransfers       = fileTransfers;
            this.TrackedFiles        = trackedFiles;
        }