예제 #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 string Generate(bool indent)
        {
            var i  = indent ? "    " : "";
            var sb = new StringBuilder();

            sb.Append($"{i}nuget_package(\n");
            if (Variable == null)
            {
                sb.Append($"{i}    name = \"{PackageIdentity.Id.ToLower()}\",\n");
            }
            else
            {
                sb.Append($"{i}    name = {Variable},\n");
            }

            sb.Append($"{i}    package = \"{PackageIdentity.Id.ToLower()}\",\n");
            sb.Append($"{i}    version = \"{PackageIdentity.Version}\",\n");
            if (!String.IsNullOrEmpty(Sha256))
            {
                sb.Append($"{i}    sha256 = \"{Sha256}\",\n");
            }
            if (NugetSourceCustom)
            {
                sb.Append($"{i}    source = source,\n");
            }
            if (CoreLib != null && CoreLib.Any())
            {
                sb.Append($"{i}    core_lib = {{\n");
                foreach (var pair in CoreLib)
                {
                    sb.Append($"{i}        \"{pair.Key}\": \"{pair.Value}\",\n");
                }
                sb.Append($"{i}    }},\n");
            }
            if (CoreRef != null && CoreRef.Any())
            {
                sb.Append($"{i}    core_ref = {{\n");
                foreach (var pair in CoreRef)
                {
                    sb.Append($"{i}        \"{pair.Key}\": \"{pair.Value}\",\n");
                }
                sb.Append($"{i}    }},\n");
            }
            if (NetLib != null && NetLib.Any())
            {
                sb.Append($"{i}    net_lib = {{\n");
                foreach (var pair in NetLib)
                {
                    sb.Append($"{i}        \"{pair.Key}\": \"{pair.Value}\",\n");
                }
                sb.Append($"{i}    }},\n");
            }
            if (NetRef != null && NetRef.Any())
            {
                sb.Append($"{i}    net_ref = {{\n");
                foreach (var pair in NetRef)
                {
                    sb.Append($"{i}        \"{pair.Key}\": \"{pair.Value}\",\n");
                }
                sb.Append($"{i}    }},\n");
            }
            if (!String.IsNullOrEmpty(MonoLib))
            {
                sb.Append($"{i}    mono_lib = \"{MonoLib}\",\n");
            }
            if (!String.IsNullOrEmpty(MonoRef))
            {
                sb.Append($"{i}    mono_ref = \"{MonoRef}\",\n");
            }
            if (CoreTool != null && CoreTool.Sum(x => x.Value.Count()) > 0)
            {
                sb.Append($"{i}   core_tool = {{\n");
                foreach (var pair in CoreTool)
                {
                    sb.Append($"{i}       \"{pair.Key}\": \"{pair.Value}\",\n");
                }
                sb.Append($"{i}   }},\n");
            }
            if (NetTool != null && NetTool.Sum(x => x.Value.Count()) > 0)
            {
                sb.Append($"{i}   net_tool = {{\n");
                foreach (var pair in NetTool)
                {
                    sb.Append($"{i}       \"{pair.Key}\": \"{pair.Value}\",\n");
                }
                sb.Append($"{i}   }},\n");
            }
            if (!String.IsNullOrEmpty(MonoTool))
            {
                sb.Append($"{i}    mono_tool = \"{MonoTool}\",\n");
            }

            if (Core_Deps != null && Core_Deps.Sum(x => x.Value.Count()) > 0)
            {
                sb.Append($"{i}    core_deps = {{\n");
                foreach (var pair in Core_Deps)
                {
                    if (!pair.Value.Any())
                    {
                        continue;
                    }

                    sb.Append($"{i}        \"{pair.Key}\": [\n");
                    foreach (var s in pair.Value)
                    {
                        sb.Append($"{i}           \"{s}\",\n");
                    }
                    sb.Append($"{i}        ],\n");
                }
                sb.Append($"{i}    }},\n");
            }

            if (Net_Deps != null && Net_Deps.Sum(x => x.Value.Count()) > 0)
            {
                sb.Append($"{i}    net_deps = {{\n");
                foreach (var pair in Net_Deps)
                {
                    if (!pair.Value.Any())
                    {
                        continue;
                    }

                    sb.Append($"{i}        \"{pair.Key}\": [\n");
                    foreach (var s in pair.Value)
                    {
                        sb.Append($"{i}           \"{s}\",\n");
                    }
                    sb.Append($"{i}        ],\n");
                }
                sb.Append($"{i}    }},\n");
            }

            if (Mono_Deps != null && Mono_Deps.Any())
            {
                sb.Append($"{i}    mono_deps = [\n");
                foreach (var s in Mono_Deps)
                {
                    sb.Append($"{i}        \"{s}\",\n");
                }
                sb.Append($"{i}    ],\n");
            }

            if (Core_Files != null && Core_Files.Sum(x => x.Value.Count()) > 0)
            {
                sb.Append($"{i}    core_files = {{\n");
                foreach (var pair in Core_Files)
                {
                    if (!pair.Value.Any())
                    {
                        continue;
                    }

                    sb.Append($"{i}        \"{pair.Key}\": [\n");
                    foreach (var s in pair.Value)
                    {
                        sb.Append($"{i}           \"{s}\",\n");
                    }
                    sb.Append($"{i}        ],\n");
                }
                sb.Append($"{i}    }},\n");
            }

            if (Net_Files != null && Net_Files.Sum(x => x.Value.Count()) > 0)
            {
                sb.Append($"{i}    net_files = {{\n");
                foreach (var pair in Net_Files)
                {
                    if (!pair.Value.Any())
                    {
                        continue;
                    }

                    sb.Append($"{i}        \"{pair.Key}\": [\n");
                    foreach (var s in pair.Value)
                    {
                        sb.Append($"{i}           \"{s}\",\n");
                    }
                    sb.Append($"{i}        ],\n");
                }
                sb.Append($"{i}    }},\n");
            }

            if (Mono_Files != null && Mono_Files.Any())
            {
                sb.Append($"{i}    mono_files = [\n");
                foreach (var s in Mono_Files)
                {
                    sb.Append($"{i}        \"{s}\",\n");
                }
                sb.Append($"{i}    ],\n");
            }
            sb.Append($"{i})\n");
            return(sb.ToString());
        }
예제 #3
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");
            }
        }
예제 #4
0
        public string Generate()
        {
            var sb = new StringBuilder();

            sb.Append($"nuget_package(\n");
            sb.Append($"   name = \"{PackageIdentity.Id.ToLower()}\",\n");
            sb.Append($"   package = \"{PackageIdentity.Id.ToLower()}\",\n");
            sb.Append($"   version = \"{PackageIdentity.Version}\",\n");
            sb.Append($"   sha256 = \"{Sha256}\",\n");
            if (!String.IsNullOrEmpty(CoreLib))
            {
                sb.Append($"   core_lib = \"{CoreLib}\",\n");
            }
            if (!String.IsNullOrEmpty(NetLib))
            {
                sb.Append($"   net_lib = \"{NetLib}\",\n");
            }
            if (!String.IsNullOrEmpty(MonoLib))
            {
                sb.Append($"   mono_lib = \"{MonoLib}\",\n");
            }
            if (!String.IsNullOrEmpty(CoreTool))
            {
                sb.Append($"   core_tool = \"{CoreTool}\",\n");
            }
            if (!String.IsNullOrEmpty(NetTool))
            {
                sb.Append($"   net_tool = \"{NetTool}\",\n");
            }
            if (!String.IsNullOrEmpty(MonoTool))
            {
                sb.Append($"   mono_tool = \"{MonoTool}\",\n");
            }

            if (Core_Deps != null && Core_Deps.Any())
            {
                sb.Append($"   core_deps = [\n");
                foreach (var s in Core_Deps)
                {
                    sb.Append($"       \"{s}\",\n");
                }
                sb.Append($"   ],\n");
            }

            if (Net_Deps != null && Net_Deps.Any())
            {
                sb.Append($"   net_deps = [\n");
                foreach (var s in Net_Deps)
                {
                    sb.Append($"       \"{s}\",\n");
                }
                sb.Append($"   ],\n");
            }

            if (Mono_Deps != null && Mono_Deps.Any())
            {
                sb.Append($"   mono_deps = [\n");
                foreach (var s in Mono_Deps)
                {
                    sb.Append($"       \"{s}\",\n");
                }
                sb.Append($"   ],\n");
            }

            if (Core_Files != null && Core_Files.Any())
            {
                sb.Append($"   core_files = [\n");
                foreach (var s in Core_Files)
                {
                    sb.Append($"       \"{s}\",\n");
                }
                sb.Append($"   ],\n");
            }

            if (Net_Files != null && Net_Files.Any())
            {
                sb.Append($"   net_files = [\n");
                foreach (var s in Net_Files)
                {
                    sb.Append($"       \"{s}\",\n");
                }
                sb.Append($"   ],\n");
            }

            if (Mono_Files != null && Mono_Files.Any())
            {
                sb.Append($"   mono_files = [\n");
                foreach (var s in Mono_Files)
                {
                    sb.Append($"       \"{s}\",\n");
                }
                sb.Append($"   ],\n");
            }
            sb.Append($")\n");
            return(sb.ToString());
        }
예제 #5
0
        public string Generate()
        {
            var sb = new StringBuilder();

            sb.Append($"nuget_package(\n");
            sb.Append($"    name = \"{PackageIdentity.Id.ToLower()}\",\n");
            sb.Append($"    package = \"{PackageIdentity.Id.ToLower()}\",\n");
            sb.Append($"    version = \"{PackageIdentity.Version}\",\n");
            if (!String.IsNullOrEmpty(Sha256))
            {
                sb.Append($"    sha256 = \"{Sha256}\",\n");
            }
            if (CoreLib != null && CoreLib.Any())
            {
                sb.Append("    core_lib = {\n");
                foreach (var pair in CoreLib)
                {
                    sb.Append($"        \"{pair.Key}\": \"{pair.Value}\",\n");
                }
                sb.Append("    },\n");
            }
            if (NetLib != null && NetLib.Any())
            {
                sb.Append("    net_lib = {\n");
                foreach (var pair in NetLib)
                {
                    sb.Append($"        \"{pair.Key}\": \"{pair.Value}\",\n");
                }
                sb.Append("    },\n");
            }
            if (!String.IsNullOrEmpty(MonoLib))
            {
                sb.Append($"    mono_lib = \"{MonoLib}\",\n");
            }
            if (CoreTool != null && CoreTool.Sum(x => x.Value.Count()) > 0)
            {
                sb.Append("   core_tool = {\n");
                foreach (var pair in NetTool)
                {
                    sb.Append($"       \"{pair.Key}\": \"{pair.Value}\",\n");
                }
                sb.Append("   },\n");
            }
            if (NetTool != null && NetTool.Sum(x => x.Value.Count()) > 0)
            {
                sb.Append("   net_tool = {\n");
                foreach (var pair in NetTool)
                {
                    sb.Append($"       \"{pair.Key}\": \"{pair.Value}\",\n");
                }
                sb.Append("   },\n");
            }
            if (!String.IsNullOrEmpty(MonoTool))
            {
                sb.Append($"    mono_tool = \"{MonoTool}\",\n");
            }

            if (Core_Deps != null && Core_Deps.Sum(x => x.Value.Count()) > 0)
            {
                sb.Append("    core_deps = {\n");
                foreach (var pair in Net_Deps)
                {
                    if (!pair.Value.Any())
                    {
                        continue;
                    }

                    sb.Append($"        \"{pair.Key}\": [\n");
                    foreach (var s in pair.Value)
                    {
                        sb.Append($"           \"{s}\",\n");
                    }
                    sb.Append("        ],\n");
                }
                sb.Append("    },\n");
            }

            if (Net_Deps != null && Net_Deps.Sum(x => x.Value.Count()) > 0)
            {
                sb.Append("    net_deps = {\n");
                foreach (var pair in Net_Deps)
                {
                    if (!pair.Value.Any())
                    {
                        continue;
                    }

                    sb.Append($"        \"{pair.Key}\": [\n");
                    foreach (var s in pair.Value)
                    {
                        sb.Append($"           \"{s}\",\n");
                    }
                    sb.Append("        ],\n");
                }
                sb.Append("    },\n");
            }

            if (Mono_Deps != null && Mono_Deps.Any())
            {
                sb.Append($"    mono_deps = [\n");
                foreach (var s in Mono_Deps)
                {
                    sb.Append($"        \"{s}\",\n");
                }
                sb.Append($"    ],\n");
            }

            if (Core_Files != null && Core_Files.Sum(x => x.Value.Count()) > 0)
            {
                sb.Append("    core_files = {\n");
                foreach (var pair in Core_Files)
                {
                    if (!pair.Value.Any())
                    {
                        continue;
                    }

                    sb.Append($"        \"{pair.Key}\": [\n");
                    foreach (var s in pair.Value)
                    {
                        sb.Append($"           \"{s}\",\n");
                    }
                    sb.Append("        ],\n");
                }
                sb.Append("    },\n");
            }

            if (Net_Files != null && Net_Files.Sum(x => x.Value.Count()) > 0)
            {
                sb.Append("    net_files = {\n");
                foreach (var pair in Net_Files)
                {
                    if (!pair.Value.Any())
                    {
                        continue;
                    }

                    sb.Append($"        \"{pair.Key}\": [\n");
                    foreach (var s in pair.Value)
                    {
                        sb.Append($"           \"{s}\",\n");
                    }
                    sb.Append("        ],\n");
                }
                sb.Append("    },\n");
            }

            if (Mono_Files != null && Mono_Files.Any())
            {
                sb.Append($"    mono_files = [\n");
                foreach (var s in Mono_Files)
                {
                    sb.Append($"        \"{s}\",\n");
                }
                sb.Append($"    ],\n");
            }
            sb.Append($")\n");
            return(sb.ToString());
        }