private HashSet GetPlatformPackageExclusions()

in src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageAssets.cs [1156:1191]


            private HashSet<string> GetPlatformPackageExclusions()
            {
                // Only exclude packages for framework-dependent applications
                if (_task.IsSelfContained && !string.IsNullOrEmpty(_runtimeTarget.RuntimeIdentifier))
                {
                    return null;
                }

                var packageExclusions = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
                var libraryLookup = _runtimeTarget.Libraries.ToDictionary(p => p.Name, StringComparer.OrdinalIgnoreCase);

                // Exclude the platform library
                if (_task.PlatformLibraryName != null)
                {
                    var platformLibrary = _runtimeTarget.GetLibrary(_task.PlatformLibraryName);
                    if (platformLibrary != null)
                    {
                        packageExclusions.UnionWith(_runtimeTarget.GetPlatformExclusionList(platformLibrary, libraryLookup));
                    }
                }

                // Exclude any runtime frameworks
                if (_task.RuntimeFrameworks != null)
                {
                    foreach (var framework in _task.RuntimeFrameworks)
                    {
                        var frameworkLibrary = _runtimeTarget.GetLibrary(framework.ItemSpec);
                        if (frameworkLibrary != null)
                        {
                            packageExclusions.UnionWith(_runtimeTarget.GetPlatformExclusionList(frameworkLibrary, libraryLookup));
                        }
                    }
                }

                return packageExclusions;
            }