Can we add support for symlink refresh to LINQPad 5+?

I'm a heavy user of LINQPad (5/8) and recently tried an experiment with one of our code bases. I wanted to pull in all the DLLs from around 75 projects but to avoid having to map paths individually to every build folder, I wrote a script that symlinks (mklink /h) all the build folder paths into one folder (using relative paths since it is shared by other team members with different root paths). This makes selecting all the DLL's very easy from the references menu in LINQPad.

I noticed using this method, LINQPad 5 doesn't seem to refresh the DLL from a symlink even if the DLL pointed to has been updated by a build. The only way I could get LINQPad to refresh was to delete and recreate all of the symlinks. Since all of our projects are currently still stuck in .NET Framework 4.7.2+ how hard would it be to fix this behavior for LINQPad 5? It would make our build-test-loop much faster if I can simply rebuild in Visual Studio and then immediately re-run my test script in LINQPad.(I'm aware a post-build script copy to a single folder would work as well but I wanted to try this to avoid the perf cost of an extra copy).

Out of interest I also tried a solution where I deleted and recreated the symlinks on-the-fly as a first step before running the script. This worked.. sort of. It required me to run it twice because the first time the DLL's get updated but LINQPad is already running in context of the old DLL's since the process is in progress. Then if I run a second time, LINQPad has properly refreshed the updated DLL's from the previous run and starts using the new code correctly. Ideally this would all happen automatically.

Thanks!

Answers

  • JoeAlbahari
    edited August 6

    I suspect this will be related to LINQPad's use of a FileSystemWatcher to monitor dependency updates. (This calls the Win32 ReadDirectoryChangesW function, which doesn't walk symlinks.)

    Another potential solution is to create a code snippet that directly references these DLLs. Right-click the editor and choose Create snippet and choose your references. Then you can activate it in any script by typing the shortcut and hitting Tab. This works in LINQPad 5.

    Yet another solution is to create an xcopy-deploy version of LINQPad for when you want to bring in these references. Create a subfolder called plugins/ and put all your DLLs there. Every script will then reference these automatically. More info here: https://www.linqpad.net/PortableDeployment.aspx

    LINQPad 6+ offers yet another option which is to write a script that references all your DLLs and then import it with the #load directive. (You can also then create a snippet to add the #load directive.)