Example #1
0
        /// <summary>
        /// Tries to create and install package request from the <paramref name="moduleInfo" />.
        /// </summary>
        /// <param name="moduleInfo">The module info.</param>
        /// <param name="installPackageRequest">The install package request.</param>
        /// <returns><c>true</c> whether the install package request is created, otherwise <c>false</c></returns>
        public bool TryCreateInstallPackageRequest(ModuleInfo moduleInfo, out InstallPackageRequest installPackageRequest)
        {
            installPackageRequest = null;
            var packageName = moduleInfo.GetPackageName();

            ModuleAssemblyRef moduleAssemblyRef = moduleInfo.GetModuleAssemblyRef(OutputDirectoryAbsoluteUri);

            if (packageName.Version != null && moduleAssemblyRef.IsInstalled)
            {
                Log.Debug("Creating local install package request for '{0}'.", packageName.Name);

                installPackageRequest = new InstallPackageRequest(moduleAssemblyRef);
            }
            else
            {
                var repositories = GetPackageRepositories().ToList();

                int i = 0;
                while (installPackageRequest == null && i < repositories.Count)
                {
                    var repository = repositories[i++];
                    if (repository != null)
                    {
                        Log.Debug("Looking for package '{0}' with version '{1}' on the repository '{2}'", packageName.Id, packageName.Version, PackageSource);

                        try
                        {
                            var package = repository.FindPackage(packageName.Id, packageName.Version);
                            if (package != null)
                            {
                                /*
                                 * IEnumerable<FrameworkName> supportedFrameworks = package.GetSupportedFrameworks();
                                 * if (supportedFrameworks != null && supportedFrameworks.Any(name => FrameworkIdentifierConversionMap.ContainsKey(name.FullName) && FrameworkIdentifierConversionMap[name.FullName].Equals(Platforms.CurrentPlatform)))
                                 * {
                                 *  Log.Debug("Creating remote install package request for '{0}' from '{1}'", package.GetFullName(), PackageSource);
                                 * }
                                 */

                                installPackageRequest = new RemoteInstallPackageRequest(this, package, GetModuleAssemblyRef(moduleInfo, package.Version));
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error(ex, "Failed to create install package request for package '{0}'", packageName.Id);
                        }
                    }
                }
            }

            return(installPackageRequest != null);
        }
Example #2
0
        /// <summary>
        /// Tries create install package request.
        /// </summary>
        /// <param name="moduleInfo">The module info</param>
        /// <param name="installPackageRequest">The install package request</param>
        /// <returns><c>true</c> if successful, <c>false</c> otherwise.</returns>
        private bool TryCreateInstallPackageRequest(ModuleInfo moduleInfo, out InstallPackageRequest installPackageRequest)
        {
            var i = 0;

            installPackageRequest = null;
            var moduleCatalogs = NuGetBasedModuleCatalogs;

            while (i < moduleCatalogs.Count && !moduleCatalogs[i].TryCreateInstallPackageRequest(moduleInfo, out installPackageRequest))
            {
                i++;
            }

            return(installPackageRequest != null);
        }
        /// <summary>
        /// Tries to create and install package request from the <paramref name="moduleInfo" />.
        /// </summary>
        /// <param name="moduleInfo">The module info.</param>
        /// <param name="installPackageRequest">The install package request.</param>
        /// <returns><c>true</c> whether the install package request is created, otherwise <c>false</c></returns>
        /// <exception cref="System.ArgumentNullException">The <paramref name="moduleInfo" /> is <c>null</c>.</exception>
        public bool TryCreateInstallPackageRequest(ModuleInfo moduleInfo, out InstallPackageRequest installPackageRequest)
        {
            Argument.IsNotNull(() => moduleInfo);

            installPackageRequest = null;
            var moduleCatalogs = ModuleCatalogs;

            int i = 0;

            while (installPackageRequest == null && i < moduleCatalogs.Count)
            {
                var moduleCatalog = moduleCatalogs[i++];
                EnsureParentChildRelationship(moduleCatalog);
                moduleCatalog.TryCreateInstallPackageRequest(moduleInfo, out installPackageRequest);
            }

            return(installPackageRequest != null);
        }