Search code examples
visual-studio-codec#-interactivedotnet-interactive.net-interactive

vscode interactive notebooks nuget directory error


I was trying to include a nuget package in my C# cell, like the example below:

#r "nuget: PackageIWantToInclude"

when suddenly, I got a similar error like this:

Error: PackageManagement Error 3217 The source directory 'D:\MyLocalDirectory' not found

note that I have not made any edits on the settings pointing to any directory with the address 'D:\MyLocalDirectory'. I've also looked for a solution elsewhere without any success. Can anyone give me a hint on how to bring the source directory back into its default?


Solution

  • Turns out, vscode interactive notebook uses the nuget configuration included in Nuget.Config found in "C:\Users{computer name}\AppData\Roaming\NuGet".

    In that current machine where the error occurs, I have some local package sources included that were already non-existent, though they were already disabled, as indicated when viewed using this command dotnet nuget list source.

    What I did was to remove the non-existent package source from the Nuget.Config file--in this example that would be:

        <add key="NonExistentSource" value="D:\MyLocalDirectory" />
    

    and then I restarted the notebook kernel by:

    • opening Command Palette (CTRL+SHFT+P) or under View>>Command Palette..
    • and then selecting the restart notebook's kernelRestart