Пример #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);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RemoteInstallPackageRequest" /> class.
        /// </summary>
        /// <param name="moduleCatalog">The module catalog.</param>
        /// <param name="package">The package.</param>
        /// <param name="moduleAssemblyRef"></param>
        /// <exception cref="System.ArgumentNullException">The <paramref name="moduleCatalog" /> is <c>null</c>.</exception>
        /// <exception cref="System.ArgumentNullException">The <paramref name="package" /> is <c>null</c>.</exception>
        public RemoteInstallPackageRequest(INuGetBasedModuleCatalog moduleCatalog, IPackage package, ModuleAssemblyRef moduleAssemblyRef)
            : base(moduleAssemblyRef)
        {
            Argument.IsNotNull(() => moduleCatalog);
            Argument.IsNotNull(() => package);

            _moduleCatalog = moduleCatalog;
            Package        = package;
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InstallPackageRequest" /> class.
        /// </summary>
        /// <param name="moduleAssemblyRef">The assembly file reference.</param>
        /// <exception cref="System.ArgumentException">The <paramref name="moduleAssemblyRef" /> is <c>null</c> or whitespace.</exception>
        public InstallPackageRequest(ModuleAssemblyRef moduleAssemblyRef)
        {
            Argument.IsNotNull(() => moduleAssemblyRef);

            this.ModuleAssemblyRef = moduleAssemblyRef;
        }