Search code examples
linqpad

Can I select nuget packages that will be installed automatically every time I create a new script?


There are a few packages that I install 95% of the time I write any scripts in Linqpad. For instance, JSON.net, is a nuget package I install every single time, and RestSharp is a close second. So my question is, is there a way to set up Linqpad to install these nuget packages by default? If not, is there a way to add them to a collection so that they can easily be installed every time?


Solution

  • There are two ways:

    • Add these packages to the My Extensions query (then they'll be implicitly referenced by all queries)
    • Add these packages to any query, and press Set as default for new queries

    Yet another option is via a code snippet. Right-click the editor and choose Create Code Snippet, then click the References checkbox to add the NuGet package. Whatever you name the snippet becomes a shortcut to add the package, so if you name the snippet json, you just type json followed by the tab key, and it will add the package.