Exemplo n.º 1
0
        public ResolvedReference ResolvePkgConfigReference(ITaskItem reference, bool specific_version)
        {
            PackageAssemblyInfo pkg = null;

            if (specific_version)
            {
                pkg = PcCache.GetAssemblyLocation(reference.ItemSpec);
            }
            else
            {
                // if not specific version, then just match simple name
                string name = reference.ItemSpec;
                if (name.IndexOf(',') > 0)
                {
                    name = name.Substring(0, name.IndexOf(','));
                }
                pkg = PcCache.ResolveAssemblyName(name).FirstOrDefault();
            }

            if (pkg == null)
            {
                LogSearchMessage("Considered {0}, but could not find in any pkg-config files.",
                                 reference.ItemSpec);
                return(null);
            }

            ResolvedReference rr = GetResolvedReference(reference, pkg.File, new AssemblyName(pkg.FullName),
                                                        false, SearchPath.PkgConfig);

            rr.FoundInSearchPathAsString = String.Format("{{PkgConfig}} provided by package named {0}",
                                                         pkg.ParentPackage.Name);

            return(rr);
        }
    public IEnumerable <ResolvedReference> GetReferencesForPackage(ITaskItem reference, string specific_version)
    {
        string package_name = reference.ItemSpec;

        log.LogMessage("Version \"{1}\" of package \"{0}\" was requested", package_name, specific_version);
        IEnumerable <LibraryPackageInfo> packages = PcCache.GetPackages();

        foreach (LibraryPackageInfo info in packages)
        {
            if (info.Assemblies != null && info.Assemblies.Count > 0 && info.Name.StartsWith(package_name))
            {
                if (!string.IsNullOrEmpty(specific_version))
                {
                    if (string.Compare(info.Version, specific_version) != 0)
                    {
                        continue;                         // try another package
                    }
                }
                foreach (PackageAssemblyInfo asm in info.Assemblies)
                {
                    AssemblyName      aname = new AssemblyName(asm.FullName);
                    ResolvedReference rr    = GetResolvedReference(reference, asm.File, aname, false, SearchPath.PkgConfig);
                    yield return(rr);
                }
                break;                 // break cycle on packages
            }
        }
    }
    public ResolvedReference ResolvePkgConfigReference(ITaskItem reference, bool specific_version = true)
    {
        var packages = PcCache.GetPackages();
        int count    = packages.Count();

        log.LogMessage("packages count = {0}", count.ToString());

        PackageAssemblyInfo pkg = null;

        pkg = PcCache.GetAssemblyLocation(reference.ItemSpec);
        log.LogMessage("PcCache.GetAssemblyLocation(\"{0}\") returned \"{1}\"", reference.ItemSpec, pkg);
        if (pkg == null)
        {
            log.LogMessage("It's null !!!");
        }
        if (pkg == null && !specific_version)
        {
            // if not specific version, then just match simple name
            string name = reference.ItemSpec;
            if (name.IndexOf(',') > 0)
            {
                name = name.Substring(0, name.IndexOf(','));
            }
            pkg = PcCache.ResolveAssemblyName(name).FirstOrDefault();
        }

        if (pkg == null)
        {
            log.LogMessage("Considered {0}, but could not find in any pkg-config files.",
                           reference.ItemSpec);
            return(null);
        }

        AssemblyName aname;

        if (!TryGetAssemblyNameFromFullName(pkg.FullName, out aname))
        {
            return(null);
        }

        ResolvedReference rr = GetResolvedReference(reference, pkg.File, aname, false, SearchPath.PkgConfig);

        rr.FoundInSearchPathAsString = String.Format("{{PkgConfig}} provided by package named {0}",
                                                     pkg.ParentPackage.Name);

        return(rr);
    }