Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newtonsoft.Json 12.0.0 from dotnet-script always imported even when 13.0.1 package installed #663

Closed
georgiosd opened this issue Feb 20, 2022 · 4 comments

Comments

@georgiosd
Copy link

georgiosd commented Feb 20, 2022

This simple script:

#r "nuget: Newtonsoft.Json, 13.0.1"

Console.WriteLine(typeof(Newtonsoft.Json.JsonConvert).Assembly);
Console.WriteLine(typeof(Newtonsoft.Json.JsonConvert).Assembly.Location);

Prints:

Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
C:\Users\georgiosd\.dotnet\tools\.store\dotnet-script\1.3.1\dotnet-script\1.3.1\tools\net6.0\any\Newtonsoft.Json.dll

😱

@filipw
Copy link
Member

filipw commented Feb 21, 2022

This is "expected". The few of own dependencies of dotnet-script are loaded into the same default assembly load context as the script. Since they are first, they win over the script ones.

You can suppress this behavior by adding the flag --isolated-load-context when running the script.

@georgiosd
Copy link
Author

@filipw perhaps it would be prudent to issue a warning for this if there is a version mismatch, for the uninitiated souls?

@billlin0904
Copy link

billlin0904 commented Sep 19, 2022

How can i set flag --isolated-load-context in vscode launch.json?

@seesharper
Copy link
Collaborator

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": ".NET Script Debug",
      "type": "coreclr",
      "request": "launch",
      "program": "${env:HOME}/.dotnet/tools/dotnet-script",
      "args": [
        "${file}",
        "--isolated-load-context"
      ],
      "windows": {
        "program": "${env:USERPROFILE}/.dotnet/tools/dotnet-script.exe",
      },
      "cwd": "${workspaceFolder}",
      "stopAtEntry": false,
    }
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants