Exemplo n.º 1
0
        /// <summary>
        /// Gets whether certain properties are the same.
        /// </summary>
        /// <param name="other">Another <see cref="ProvidesDependency"/> to compare.</param>
        /// <remarks>This is not the same as object equality, but only checks a subset of properties
        /// to determine if the objects are similar and could be merged into a collection.</remarks>
        /// <returns>True if certain properties are the same.</returns>
        internal bool Equals(ProvidesDependency other)
        {
            if (null != other)
            {
                return(this.Key == other.Key &&
                       this.Version == other.Version &&
                       this.DisplayName == other.DisplayName);
            }

            return(false);
        }
Exemplo n.º 2
0
//#region DependencyExtension
        /// <summary>
        /// Imports authored dependency providers for each package in the manifest,
        /// and generates dependency providers for certain package types that do not
        /// have a provider defined.
        /// </summary>
        /// <param name="bundle">The <see cref="Output"/> object for the bundle.</param>
        /// <param name="facades">An indexed collection of chained packages.</param>
        private void ProcessDependencyProviders(Output bundle, IDictionary <string, PackageFacade> facades)
        {
            // First import any authored dependencies. These may merge with imported provides from MSI packages.
            Table wixDependencyProviderTable = bundle.Tables["WixDependencyProvider"];

            if (null != wixDependencyProviderTable && 0 < wixDependencyProviderTable.Rows.Count)
            {
                // Add package information for each dependency provider authored into the manifest.
                foreach (Row wixDependencyProviderRow in wixDependencyProviderTable.Rows)
                {
                    string packageId = (string)wixDependencyProviderRow[1];

                    PackageFacade facade = null;
                    if (facades.TryGetValue(packageId, out facade))
                    {
                        ProvidesDependency dependency = new ProvidesDependency(wixDependencyProviderRow);

                        if (String.IsNullOrEmpty(dependency.Key))
                        {
                            switch (facade.Package.Type)
                            {
                            // The WixDependencyExtension allows an empty Key for MSIs and MSPs.
                            case WixBundlePackageType.Msi:
                                dependency.Key = facade.MsiPackage.ProductCode;
                                break;

                            case WixBundlePackageType.Msp:
                                dependency.Key = facade.MspPackage.PatchCode;
                                break;
                            }
                        }

                        if (String.IsNullOrEmpty(dependency.Version))
                        {
                            dependency.Version = facade.Package.Version;
                        }

                        // If the version is still missing, a version could not be harvested from the package and was not authored.
                        if (String.IsNullOrEmpty(dependency.Version))
                        {
                            Messaging.Instance.OnMessage(WixErrors.MissingDependencyVersion(facade.Package.WixChainItemId));
                        }

                        if (String.IsNullOrEmpty(dependency.DisplayName))
                        {
                            dependency.DisplayName = facade.Package.DisplayName;
                        }

                        if (!facade.Provides.Merge(dependency))
                        {
                            Messaging.Instance.OnMessage(WixErrors.DuplicateProviderDependencyKey(dependency.Key, facade.Package.WixChainItemId));
                        }
                    }
                }
            }

            // Generate providers for MSI packages that still do not have providers.
            foreach (PackageFacade facade in facades.Values)
            {
                string key = null;

                if (WixBundlePackageType.Msi == facade.Package.Type && 0 == facade.Provides.Count)
                {
                    key = facade.MsiPackage.ProductCode;
                }
                else if (WixBundlePackageType.Msp == facade.Package.Type && 0 == facade.Provides.Count)
                {
                    key = facade.MspPackage.PatchCode;
                }

                if (!String.IsNullOrEmpty(key))
                {
                    ProvidesDependency dependency = new ProvidesDependency(key, facade.Package.Version, facade.Package.DisplayName, 0);

                    if (!facade.Provides.Merge(dependency))
                    {
                        Messaging.Instance.OnMessage(WixErrors.DuplicateProviderDependencyKey(dependency.Key, facade.Package.WixChainItemId));
                    }
                }
            }
        }