Skip to content

Global dependency groups in .nuspec files are incorrectly parsed as "unsupported" instead of "any" #14685

@quasarea

Description

@quasarea

NuGet Product Used

NuGet SDK

Product Version

7.3.0-preview.1.10

Worked before?

nope

Impact

It's more difficult to complete my work

Repro Steps & Context

Global dependency groups in .nuspec files are incorrectly parsed as "unsupported" instead of "any"

Problem

Dependency groups in .nuspec files that don't specify a targetFramework attribute (global dependencies) are incorrectly parsed as UnsupportedFramework instead of AnyFramework. This causes them to display as "unsupported" in tools like NuGet Package Explorer, rather than "any".

Steps to Reproduce

  1. Create a .nuspec file with global dependencies like this:

    <dependencies>
      <group>
        <dependency id="SomePackage" version="1.0.0" />
      </group>
      <group targetFramework="netstandard2.0">
        <dependency id="AnotherPackage" version="2.0.0" />
      </group>
    </dependencies>
  2. Pack the package and open it in NuGet Package Explorer

  3. Observe that the first dependency group (without targetFramework) shows as "unsupported" instead of "any"

Expected Behavior

The dependency group without targetFramework should be treated as targeting "any" framework, displaying as "any" in the UI.

Actual Behavior

The dependency group without targetFramework is parsed as UnsupportedFramework, displaying as "unsupported" in the UI.

Root Cause

ManifestReader.ReadDependencyGroups (used by Manifest.ReadFrom) defaults to UnsupportedFramework when the targetFramework attribute is missing from a dependency group.

Solution

Modified ManifestReader.ReadDependencyGroups to use AnyFramework when targetFramework is missing or empty.

Files Changed

  • src/NuGet.Core/NuGet.Packaging/PackageCreation/Authoring/ManifestReader.cs

Impact

This affects any package with global dependencies (dependencies that apply to all frameworks). Tools that display dependency information will show incorrect framework information.

Environment

  • NuGet.Client version: dev branch
  • .NET version: 8.0/10.0
  • OS: Windows

Verbose Logs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions