NuGet Integration!

edited December 2012
For LINQPad Premium users, I've just released a beta with NuGet integration:
www.linqpad.net/beta.aspx

The idea is to use LINQPad as a scratchpad for NuGet packages. Click on a package and use LINQPad to experiment with it, exploring its functionality in an immediate, fun and .Dump()-friendly environment.

Go to query properties (F4) and click "Add NuGet". NuGet references are treated as first-class, so you can save them to snippets, use them in "My Extensions" and in defaults for new queries. When you update a NuGet reference, the effect is global, so saved queries will reference the latest version. And if you send a .linq file with a NuGet reference to someone else, it will ask them whether they'd like to download the NuGet library automatically upon opening the query.

Let me know how you get on!

Joe

Comments

  • This is great news. Thanks so much for all your hard work.
  • Great work! I just got one concern over package versions. If I understand correctly LinqPad only handle one version of a package. When later I update a package all the queries using it will need to be upgraded (if the new version introduce breaking changes).

    I just hope it doesn't happen to often.
  • Yes: LINQPad will handle just one version of each package.

    (The exception is dependencies, where LINQPad honors the package's versioning policy.)

    No: You don't need to update each query after updating a NuGet package. LINQPad handles this automatically. In fact, each query stores only the names of the NuGet packages that it references, not specific version numbers. It works out what version to use when you run the query.

    So if a new version introduces breaking changes, yes, queries could break. If you think this is wrong, let me know how you think it should be solved. The problem with having each query reference a specific package version (like projects do in VS), is that updating a package globally would become cumbersome, because you might have dozens of queries referencing the old version. Each would need to be upgraded separately.

    Of course, it could be an option, so after adding a NuGet reference, you could request that the query "lock in" to that version. But the difficulty with that is that you can't know in advance whether you'd want to apply a future update or not. The next release could contain an essential bug fix, be faster, and have a new feature that you requested. Or it could contain breaking changes. So, let's say you write and save a dozen queries that use Reactive Framework. Would you lock them into the current version or not?

    Another factor is how to do it without complicating the UI (especially if it turns out to be a 1% scenario). I imagine most people want something that's simple and that "just works".
  • Hi,

    Yes I agree with your analysis. I really don't expect the current behaviour to cause a lot of trouble, I'm just stating that it could happen. I think it's the control freak in me who likes to control all dependencies of an application and of queries (I'm an architect you see :-).

    Better keep it simple.
  • Installing Hammock REST package doesn't work in Linqpad; this package provides two DLLs, one for .Net client profile and one for the full profile - in Visual Studio you get a reference to the correct one, but in Linqpad, both are referenced and you end up with a message along the lines of type X exists in both Y.dll and Z.dll.
  • I'll look into why this is so.

    In the meantime, there's a simple workaround. After adding the reference to the NuGet package, click Close and then click the NuGet hyperlink in the 'Additional References' list. Select the option "Show assemblies in this package" and exclude Hammock.ClientProfile.dll. This will apply to all queries, so you'll have to do it only once.
  • Hi Joe,

    Just trying to add a NuGet package in the latest beta ( 4.42.04 AnyCPU) via F4 and get a message saying that "Adding NuGet packages is only supported in LinqPad premium". I take it that premium means the autocompletion (which i have) is there any thing else i need to do??
  • There are two pay editions - LINQPad Pro and LINQPad Premium. Both have autocompletion, but only the latter allows cross-database querying and NuGet. You can upgrade for $25 until end of this month here: http://www.linqpad.net/PurchaseUpgrade.aspx
  • I’m having an issue connecting from behind a proxy. As the ‘LinqPad NuGet Manager’ page is opened I get a ‘The remote server returned an error: (407) Proxy Auth Required’ in a message box. I’ve got my proxy settings set to ‘manual Specify Proxy’ (under Edit->Preferences->Updates), clicking ‘Test’ returns success. I’m guessing these settings are only for updates ATM?

    I image I can work around this by specifying the proxy under system.net in LINQPad.exe.config but haven’t tried that yet, just letting you know in case this is something that requires fixing.
  • I've just uploaded a beta that enables proxy settings with NuGet which you might like to try. However, I haven't had any luck in getting through the proxies I've tried - the NuGet library itself seems to throws with feeds that use HTTPS (including the default nuget.org feed). FWIW, I experience the same problem in Visual Studio.
  • edited November 2012
    Hi Joe,

    I've just upgraded to Premium for the Nuget support but can't get it to work. I'm also behind an authenticated proxy. I've added my proxy details to LinqPad. (The proxy address is http:// then the IP, and I've specified domain username/password). If I click Test it says it was successful, and checking for updates seems to suggest it's OK).

    However when adding Nuget packages it says "NuGet.Core threw an exception. The remote server return an error: (407) Proxy Authentication Required".

    One slightly odd thing about our arrangement here - I develop in a different domain to the internet proxy server so need to log in to be able to access it. (But, as mentioned, for LinqPad I have some credentials I can specify.)

    Outside Nuget, if I go to "Download/import more samples" I get "This program cannot display the webpage". (I've never been too fussed about this not working here to be honest).

    I'm using v4.43.04.

    One other thing - I tried Keith's suggestion and added an authenticated proxy to my config file. It didn't seem to make a difference but I'm not sure if I've done it right!

    John
  • Just want to say that I love this feature, but I would like the ability to lock a query to a specific version of a NuGet package. I use LINQPad a lot to write simple examples of how to do things in my NAudio libarary. But sometimes I want to use the release version, and sometimes I want to use the pre-release version, and LINQPad makes all my queries use the same version. Also more generally, I think its safer to stick with the version of dependency that you wrote the query with, and only upgrade to a newer version if you specifically ask to. It would not bother me that my queries don't all auto-upgrade to newer versions, in fact I'd consider that a good thing.

    anyway, thanks again for what is one of my favourite development utilities.
  • John - can you try the latest beta? It uses another technique to penetrate proxies for NuGet.
  • Mark - while you cannot tell LINQPad to use a specific package version, LINQPad does respect your decision as to whether to use the release version or pre-release version on a per-query basis.

    In other words, LINQPad considers pre-release packages to have a different identity to release packages. So you can safely have one query referencing the latest pre-release version and another referencing the latest release version.
  • Hi Joe,

    Just upgraded to 4.43.06 but I'm afraid I'm still getting a 407 access denied error. I presume it uses the same web proxy as the rest of LinqPad? Just to clarify - I am specifying a proxy address, port and also credentials in here. If I use "automatically detect proxy" I get the 407 when I click Test as well.

    I've tried with/without the "Disable Expect-100-Continue" and it doesn't seem to make a difference.

    Sorry. :(

    John
  • Hi Joe,

    I see this is no longer a beta. Are you still looking into this or is there anything I can do to maybe workaround the issue?

    I'm using Windows 2003 if that makes a difference. I could try to find a Win 2008 server to install it onto?

    John
  • The .06 build passes the proxy details correctly to NuGet.Core, and I've verified that it works with two different proxy servers. If it still fails for you, I imagine there's a subtle problem somewhere in NuGet.Core (perhaps related to the proxy server being on a different domain). It's hard to know what to suggest from here.
  • That's strange because it works fine in Visual Studio. (Or is it not quite the same thing?) You don't have any test code I could try stepping through to see if I can figure out where it's failing do you?
  • Is VS picking up the settings from IE?
  • Yes, I think it must be as I never entered in any proxy details into Visual Studio (and can't find any options to do that.) When I fire up Nuget from visual studio it prompts me for credentials before it works. If I set LinqPad to use automatic proxy it just gives me authorization required (407) without prompting. (Regardless of whether it's using the "test" button in the proxy dialog or from nuget)
  • And have you entered the proxy server details in LINQPad *exactly* as you have in IE's Internet Options?
  • edited December 2012
    Well, not *exactly* in the sense that the LinqPad options are slightly different.

    For example, in IE I put the IP of the proxy. In LinqPad I need to enter http:// in front of the IP. Also IE doesn't have options for credentials so I can't put them in there, whereas LinqPad does. But the IP address and port used are the same.

    The Test button does work in the LinqPad settings, and LinqPad can check for updates OK. But, as mentioned, when I click "Download/import more settings" from the Samples tab I do get "This program cannot display the webpage"
  • I've just had another try today with different credentials and it has worked! Not quite sure why the other set doesn't, but it does look like it's a problem this end after all.

    Sorry for any hassles caused! Great to have it working now!
  • Is there a way to get to the NuGet settings dialog without going through the LINQPad NuGet Manager?

    I have a script that uses a package from an internal NuGet feed and need people to add that to the list of Package Sources in LINQPad. Unfortunately they now get the "only when you pay" warning when they go F4 > Add NuGet...

    I'd love for all of them to register LINQPad of course, but for now the message seems to scare them away from using my scripts. I couldn't find another option in the menu that leads to the Package Sources, but maybe I am overlooking something?
  • Your script should work whether or not users are registered. The premium feature only controls whether users can see the dialog to add new packages.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!