コード例 #1
0
        private static VsTargetFrameworkInfo ToTargetFrameworkInfo(
            TargetFrameworkInformation tfm,
            IEnumerable <IVsProjectProperty> globalProperties)
        {
            var packageReferences = tfm
                                    .Dependencies
                                    .Where(d => d.LibraryRange.TypeConstraint == LibraryDependencyTarget.Package)
                                    .Select(ToPackageReference);

            var projectReferences = tfm
                                    .Dependencies
                                    .Where(d => d.LibraryRange.TypeConstraint == LibraryDependencyTarget.ExternalProject)
                                    .Select(ToProjectReference);

            var projectProperties = new VsProjectProperties
            {
                {
                    "PackageTargetFallback",
                    string.Join(";", tfm.Imports.Select(x => x.GetShortFolderName()))
                },
            };

            return(new VsTargetFrameworkInfo(
                       tfm.FrameworkName.ToString(),
                       packageReferences,
                       projectReferences,
                       projectProperties.Concat(globalProperties),
                       originalTargetFramework: tfm.TargetAlias));
        }
コード例 #2
0
        private static VsTargetFrameworkInfo2 ToTargetFrameworkInfo2(
            TargetFrameworkInformation tfm,
            IEnumerable <IVsProjectProperty> globalProperties)
        {
            var packageReferences = tfm
                                    .Dependencies
                                    .Where(d => d.LibraryRange.TypeConstraint == LibraryDependencyTarget.Package)
                                    .Select(ToPackageReference);

            var projectReferences = tfm
                                    .Dependencies
                                    .Where(d => d.LibraryRange.TypeConstraint == LibraryDependencyTarget.ExternalProject)
                                    .Select(ToProjectReference);

            var packageDownloads = tfm
                                   .DownloadDependencies
                                   .Select(ToPackageDownload);

            var frameworkReferences = tfm.FrameworkReferences.Select(e => new VsReferenceItem(e, new VsReferenceProperties()));

            var projectProperties = new VsProjectProperties
            {
                {
                    "PackageTargetFallback",
                    string.Join(";", tfm.Imports.Select(x => x.GetShortFolderName()))
                }
            };

            return(new VsTargetFrameworkInfo2(
                       tfm.FrameworkName.ToString(),
                       packageReferences,
                       projectReferences,
                       packageDownloads,
                       frameworkReferences,
                       projectProperties.Concat(globalProperties)));
        }