예제 #1
0
        public WorkspaceEntry(PackageIdentity identity, string sha256, IEnumerable <PackageDependencyGroup> deps,
                              IEnumerable <FrameworkSpecificGroup> libs, IEnumerable <FrameworkSpecificGroup> tools, IEnumerable <FrameworkSpecificGroup> references,
                              string mainFile)
        {
            PackageIdentity = identity;
            Sha256          = sha256;

            var coreFramework = NuGetFramework.Parse("netcoreapp5.0");
            var netFramework  = NuGetFramework.Parse("net70");
            var monoFramework = NuGetFramework.Parse("net70");

            Core_Files = GetFiles(coreFramework, libs, tools);
            Net_Files  = GetFiles(netFramework, libs, tools);
            Mono_Files = GetFiles(monoFramework, libs, tools);

            var depConverted = deps.Select(x =>
                                           new FrameworkSpecificGroup(x.TargetFramework, x.Packages.Select(y => y.Id.ToLower())));

            Core_Deps = MSBuildNuGetProjectSystemUtility.GetMostCompatibleGroup(coreFramework, depConverted)?.Items?.Select(x => ToRef(x, "core"));
            Net_Deps  = MSBuildNuGetProjectSystemUtility.GetMostCompatibleGroup(netFramework, depConverted)?.Items?.Select(x => ToRef(x, "net"));
            Mono_Deps = MSBuildNuGetProjectSystemUtility.GetMostCompatibleGroup(monoFramework, depConverted)?.Items?.Select(x => ToRef(x, "mono"));

            CoreLib = GetMostCompatibleItem(coreFramework, references, mainFile);
            NetLib  = GetMostCompatibleItem(netFramework, references, mainFile);
            MonoLib = GetMostCompatibleItem(monoFramework, references, mainFile);

            CoreTool = GetMostCompatibleItem(coreFramework, tools, mainFile);
            NetTool  = GetMostCompatibleItem(netFramework, tools, mainFile);
            MonoTool = GetMostCompatibleItem(monoFramework, tools, mainFile);

            if (CoreLib == null)
            {
                CoreLib = Core_Files?.FirstOrDefault(x => Path.GetExtension(x) == ".dll");
            }
            if (NetLib == null)
            {
                NetLib = Net_Files?.FirstOrDefault(x => Path.GetExtension(x) == ".dll");
            }
            if (CoreLib == null)
            {
                CoreLib = NetLib;
            }

            if (MonoLib == null)
            {
                MonoLib = Mono_Files?.FirstOrDefault(x => Path.GetExtension(x) == ".dll");
            }
        }
예제 #2
0
        public WorkspaceEntry(PackageIdentity identity, string sha256, IEnumerable <PackageDependencyGroup> deps,
                              IEnumerable <FrameworkSpecificGroup> libs, IEnumerable <FrameworkSpecificGroup> tools, IEnumerable <FrameworkSpecificGroup> references,
                              string mainFile)
        {
            var netFrameworkTFMs = new string[]
            {
                "net45", "net451", "net452", "net46", "net461", "net462", "net47", "net471", "net472", "netstandard1.0",
                "netstandard1.1", "netstandard1.2", "netstandard1.3",
                "netstandard1.4", "netstandard1.5", "netstandard1.6", "netstandard2.0",
            };
            var coreFrameworkTFMs = new string[]
            {
                "netcoreapp2.0", "netcoreapp2.1",
            };

            PackageIdentity = identity;
            Sha256          = sha256;

            var coreFrameworks = coreFrameworkTFMs.Select(x => NuGetFramework.Parse(x));
            var netFrameworks  = netFrameworkTFMs.Select(x => NuGetFramework.Parse(x));
            var monoFramework  = NuGetFramework.Parse("net70");

            Core_Files = GetFiles(coreFrameworks, libs, tools);
            Net_Files  = GetFiles(netFrameworks, libs, tools);
            Mono_Files = GetFiles(monoFramework, libs, tools);

            var depConverted = deps.Select(x =>
                                           new FrameworkSpecificGroup(x.TargetFramework, x.Packages.Select(y => y.Id.ToLower())));

            Core_Deps = GetDeps(coreFrameworks, depConverted);
            Net_Deps  = GetDeps(netFrameworks, depConverted);
            Mono_Deps = MSBuildNuGetProjectSystemUtility.GetMostCompatibleGroup(monoFramework, depConverted)?.Items?.Select(x => ToRefMono(x));

            CoreLib = new Dictionary <string, string>();
            foreach (var framework in coreFrameworks)
            {
                var lib = GetMostCompatibleItem(framework, references, libs, mainFile);
                if (lib != null)
                {
                    CoreLib.Add(framework.GetShortFolderName(), lib);
                }
            }
            NetLib = new Dictionary <string, string>();
            foreach (var framework in netFrameworks)
            {
                var lib = GetMostCompatibleItem(framework, references, libs, mainFile);
                if (lib != null)
                {
                    NetLib.Add(framework.GetShortFolderName(), lib);
                }
            }
            MonoLib = GetMostCompatibleItem(monoFramework, references, mainFile);

            CoreTool = new Dictionary <string, string>();
            foreach (var framework in coreFrameworks)
            {
                var tool = GetMostCompatibleItem(framework, tools, mainFile);
                if (tool != null)
                {
                    CoreTool.Add(framework.GetShortFolderName(), tool);
                }
            }
            NetTool = new Dictionary <string, string>();
            foreach (var framework in netFrameworks)
            {
                var tool = GetMostCompatibleItem(framework, tools, mainFile);
                if (tool != null)
                {
                    NetTool.Add(framework.GetShortFolderName(), tool);
                }
            }
            MonoTool = GetMostCompatibleItem(monoFramework, tools, mainFile);

            if (CoreLib == null)
            {
                CoreLib = Core_Files?.ToDictionary(key => key.Key, val => val.Value.FirstOrDefault(z => Path.GetExtension(z) == ".dll"));
            }
            if (NetLib == null || !NetLib.Any())
            {
                NetLib = Net_Files?.ToDictionary(key => key.Key, val => val.Value.FirstOrDefault(z => Path.GetExtension(z) == ".dll"));
            }
            if (CoreLib == null || !CoreLib.Any())
            {
                CoreLib = Core_Files?.ToDictionary(key => key.Key, val => val.Value.FirstOrDefault(z => Path.GetExtension(z) == ".dll"));
            }

            if (MonoLib == null)
            {
                MonoLib = Mono_Files?.FirstOrDefault(x => Path.GetExtension(x) == ".dll");
            }
        }