Skip to content

generate-load-scripts drops self-referencing assemblies (System.Reactive 7.0) from group load script #4458

Closed

Description

@fpellet

Description

Since System.Reactive 7.0.0, generate-load-scripts silently drops System.Reactive.dll from the <group>.group.fsx script, while the per-package System.Reactive.fsx script still references it. Any script loading the group file then fails (e.g. FAKE's Fake.Core.Target → FSharp.Control.Reactive → System.Reactive fails with FileNotFoundException: Could not load file or assembly 'System.Reactive, Version=5.0.0.0').

Repro steps

paket.dependencies:

source https://api.nuget.org/v3/index.json
framework: net10.0
storage: none
generate_load_scripts: true

nuget FSharp.Core
nuget System.Reactive 7.0.0

test.fsx:

#load ".paket/load/main.group.fsx"
System.Reactive.Linq.Observable.Return 42 |> printfn "%A"
paket install
dotnet fsi test.fsx

Expected behavior

.paket/load/main.group.fsx contains #r ".../system.reactive/7.0.0/lib/net8.0/System.Reactive.dll" and the script prints the observable (this is what happens with System.Reactive 6.1.0).

Actual behavior

.paket/load/main.group.fsx is empty:

namespace PaketLoadScripts

while .paket/load/System.Reactive.fsx is correct:

namespace PaketLoadScripts

#r "/home/<user>/.nuget/packages/system.reactive/7.0.0/lib/net8.0/System.Reactive.dll"

and dotnet fsi test.fsx fails with:

error FS0039: The value, constructor, namespace or type 'Reactive' is not defined.

Note: FSharp.Core (or any second package) is needed to reproduce, because getDllOrder short-circuits when there is a single dll.

Root cause

System.Reactive.dll 7.0.0 (lib/net8.0) contains an assembly reference to itself (monodis --assemblyref lists System.Reactive, Version=7.0.0.0 among its references; 6.1.0 does not).

In src/Paket.Core/PaketConfigFiles/DependencyCache.fs, the group script orders dlls with getDllOrder:

let known = dllFiles |> Seq.map (fun a -> a.FullName) |> Set.ofSeq
getPackageOrderGeneric
    (fun (p:AssemblyDefinition) -> p.FullName)
    (fun p -> p.MainModule.AssemblyReferences |> Seq.map (fun r -> r.FullName) |> Seq.filter known.Contains)
    dllFiles

The self-reference survives the known.Contains filter, so the assembly depends on itself and is never selected as a leaf by getLeafPackagesGeneric. getPackageOrderGeneric then stops on | [], _, _ -> finalList and silently discards every remaining item (any reference cycle would be dropped the same way).

The per-package script is unaffected because it contains a single dll and getDllOrder returns early (if List.length dllFiles = 1 then dllFiles).

Suggested fix

  • Ignore self-references when computing dll dependencies in getDllOrder (e.g. |> Seq.filter (fun r -> r <> p.FullName)).
  • Do not silently drop items left unordered by getPackageOrderGeneric (cycles): append them at the end and/or emit a warning.
  • Add a unit test covering an assembly that references itself.

Known workarounds

Constrain the version: nuget System.Reactive < 7.

Environment

Paket 10.3.1 / 11.0.1 / 12.0.0-alpha002, .NET SDK 10, Linux.

Activity

  1. fpellet commented on Oct 21, 2026

    @fpellet
    CollaboratorAuthor

    /repo-assist Please fix this issue: in DependencyCache.getDllOrder, ignore assembly self-references, and make getPackageOrderGeneric keep (append, with a warning) items it cannot order instead of silently dropping them. Add a regression test with an assembly referencing itself (e.g. System.Reactive 7.0.0 alongside FSharp.Core, per the repro above) and open a draft PR.

  2. github-actions commented on Oct 21, 2026

    @github-actions
    Contributor

    ✓ Repo Assist completed successfully, see workflow run.

    Generated by 🌈 Repo Assist, see workflow run. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions