コード例 #1
0
        /// <summary>
        /// Gets the target framework information for the specified project.  This includes the package references, package downloads, and framework references.
        /// </summary>
        /// <param name="projectInnerNodes">An <see cref="IReadOnlyDictionary{NuGetFramework,ProjectInstance} "/> containing the projects by their target framework.</param>
        /// <returns>A <see cref="List{TargetFrameworkInformation}" /> containing the target framework information for the specified project.</returns>
        private static List <TargetFrameworkInformation> GetTargetFrameworkInfos(IReadOnlyDictionary <NuGetFramework, IMSBuildProject> projectInnerNodes)
        {
            var targetFrameworkInfos = new List <TargetFrameworkInformation>(projectInnerNodes.Count);

            foreach (var projectInnerNode in projectInnerNodes)
            {
                var msBuildProjectInstance = projectInnerNode.Value;

                var targetFrameworkInformation = new TargetFrameworkInformation
                {
                    FrameworkName = projectInnerNode.Key,
                    RuntimeIdentifierGraphPath = msBuildProjectInstance.GetProperty(nameof(TargetFrameworkInformation.RuntimeIdentifierGraphPath))
                };

                var packageTargetFallback = MSBuildStringUtility.Split(msBuildProjectInstance.GetProperty("PackageTargetFallback")).Select(NuGetFramework.Parse).ToList();

                var assetTargetFallback = MSBuildStringUtility.Split(msBuildProjectInstance.GetProperty(nameof(TargetFrameworkInformation.AssetTargetFallback))).Select(NuGetFramework.Parse).ToList();

                AssetTargetFallbackUtility.EnsureValidFallback(packageTargetFallback, assetTargetFallback, msBuildProjectInstance.FullPath);

                AssetTargetFallbackUtility.ApplyFramework(targetFrameworkInformation, packageTargetFallback, assetTargetFallback);

                targetFrameworkInformation.Dependencies.AddRange(GetPackageReferences(msBuildProjectInstance));

                targetFrameworkInformation.DownloadDependencies.AddRange(GetPackageDownloads(msBuildProjectInstance));

                targetFrameworkInformation.FrameworkReferences.AddRange(GetFrameworkReferences(msBuildProjectInstance));

                targetFrameworkInfos.Add(targetFrameworkInformation);
            }

            return(targetFrameworkInfos);
        }
コード例 #2
0
        static void AddPackageTargetFallbacks(PackageSpec packageSpec, IDotNetProject project)
        {
            var packageTargetFallback = GetPackageTargetFallbackList(project)
                                        .Select(NuGetFramework.Parse)
                                        .ToList();

            var assetTargetFallback = GetAssetTargetFallbackList(project)
                                      .Select(NuGetFramework.Parse)
                                      .ToList();

            if (!packageTargetFallback.Any() && !assetTargetFallback.Any())
            {
                return;
            }

            AssetTargetFallbackUtility.EnsureValidFallback(
                packageTargetFallback,
                assetTargetFallback,
                packageSpec.FilePath);

            var frameworks = GetProjectFrameworks(project);

            foreach (var framework in frameworks)
            {
                var frameworkInfo = packageSpec.GetTargetFramework(framework);
                AssetTargetFallbackUtility.ApplyFramework(frameworkInfo, packageTargetFallback, assetTargetFallback);
            }
        }