예제 #1
0
        public static string GetPackageAssemblySearchPath(
            LocalPackageInfo packageInfo,
            NuGetFramework framework)
        {
            if (packageInfo == null)
            {
                return(null);
            }

            if (framework == null)
            {
                throw new ArgumentNullException(nameof(framework));
            }

            var possibleFrameworks = packageInfo.Files
                                     .Select(path => path.Split(new [] { '/', '\\' }))
                                     .Where(parts => string.Equals(parts [0], "lib", StringComparison.OrdinalIgnoreCase))
                                     .Select(parts => NuGetFramework.ParseFolder(parts [1].ToLowerInvariant()))
                                     .Distinct();

            var bestFramework = new FrameworkReducer()
                                .GetNearest(framework, possibleFrameworks);

            return(Path.Combine(
                       packageInfo.ExpandedPath,
                       "lib",
                       bestFramework.GetShortFolderName()));
        }