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
Feature Request: NuGet Pragma #1220
Comments
Thanks for the suggestions.
We chose to have dependencies externalized from code as this was a common
established pattern that .NET as well as platforms like node, python, java,
ruby etc all adhere to.
That being said, I see value in #p or #n or something that allows you to
specify a package reference from within a script. #r should work today for
local assemblies.
Great idea on allowing a script-specific packages.config. That would
definitely be useful for when there are multiple scripts in a folder with
different dependencies.
…On Thu, Feb 23, 2017 at 7:16 AM William Kempf ***@***.***> wrote:
Using scriptcs -install seems a bit of a hack, to be honest. This results
in having to maintain multiple files. Cake and other Roslyn based tools
allow you to reference NuGet packages within the script itself. It would be
great if scriptcs worked the same way.
#r SomeLocalAssembly
#n SomeNuGetPackage
The #n directive would install the NuGet package(s) to a local folder
(probably packages) and then reference it(them).
While making this suggestion, I'll make another. Instead of using a
generic "scriptcs_packages.config" file, use a "*scriptname*_packages.config"
file. This would allow your scripts to be in the same directory without
having conflicts with the packages used (i.e. each script can use their own
NuGet package versions, and restore only has to work with that scripts
packages). Or, work more like the new CSPROJ and require version numbers
with the #n and don't use any config file.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1220>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAInRATKCBkT23xo_H1N8_IRz6vqdo09ks5rfaLTgaJpZM4MKFyK>
.
|
For large multi-script projects external dependencies may make sense. I want to use scriptcs like a replacement for LinqPad, though, and in scenarios like that working with multiple files is more of a PITA than any sort of help. So, I'm glad you're receptive to the idea. :) Makes sense to me to support both modes, though that may lead to some confusion? |
Cool. Yeah I think we can potentially support all 3. The one complexity
here is we'd have to have precedence rules. Like what happens if you use a
#n and you have a foo_scriptcs_packages.config and
scriptcs_packages.config. One way to simplify that would be to only allow
you to have one of the 3. An advantage of the separate configs is it allows
you to only load the packages your script needs.
…On Fri, Feb 24, 2017 at 5:24 AM William Kempf ***@***.***> wrote:
For large multi-script projects external dependencies may make sense. I
want to use scriptcs like a replacement for LinqPad, though, and in
scenarios like that working with multiple files is more of a PITA than any
sort of help. So, I'm glad you're receptive to the idea. :) Makes sense to
me to support both modes, though that may lead to some confusion?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1220 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAInRKuNfPPjdfYAy8eGKM3DANiAEr3Oks5rftn1gaJpZM4MKFyK>
.
|
Personally, I'd go with precedence script > script_packages.config > scriptcs_packages.config. Yes, both of the first two modes mean you only load the packages you need. |
Precedence adds complexity since the same package could be overridden
versioning wise. Not allowing multiple simplifies the implementation,
…On Fri, Feb 24, 2017 at 11:52 AM William Kempf ***@***.***> wrote:
Personally, I'd go with precedence script > script_packages.config >
scriptcs_packages.config. Yes, both of the first two modes mean you only
load the packages you need.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1220 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAInRH6D7CCHfscupXw3Y5GVxB3IXpuFks5rfzUNgaJpZM4MKFyK>
.
|
I'm fine with that. I can't imagine why you'd use more than one "mode" here, so it mostly won't make a difference in practice (though obviously you have to take a stance in the implementation). I wasn't meaning to suggest I prefer precedence, only that if you used precedence I preferred that order. What ever is easiest to deal with in the implementation should be fine. |
Sure. I completely get why you'd want it. I will take a look at what it
will take. Is this something you'd like to help with or implement?
…On Fri, Feb 24, 2017 at 11:56 AM William Kempf ***@***.***> wrote:
I'm fine with that. I can't imagine why you'd use more than one "mode"
here, so it mostly won't make a difference in practice (though obviously
you have to take a stance in the implementation). I wasn't meaning to
suggest I prefer precedence, only that if you used precedence I preferred
that order. What ever is easiest to deal with in the implementation should
be fine.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1220 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAInRIgcHBzQyF248wNQnw_Hrn0QmdDdks5rfzYFgaJpZM4MKFyK>
.
|
Thinking about it... there's precedence even if you only use one mode. So, if there's a #r it should only use pragmas. If there's no pragmas, but a scriptname_packages.config it should use that. If there's neither it should use scriptcs_config.packages if it exists. I wouldn't mind helping... except my plate is pretty full at the moment. Can't really commit to it right now. :( |
Mine too, this is definitely not my day job :-)
…On Fri, Feb 24, 2017 at 12:00 PM William Kempf ***@***.***> wrote:
Thinking about it... there's precedence even if you only use one mode. So,
if there's a #r it should only use pragmas. If there's no pragmas, but a
scriptname_packages.config it should use that. If there's neither it should
use scriptcs_config.packages if it exists.
I wouldn't mind helping... except my plate is pretty full at the moment.
Can't really commit to it right now. :(
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1220 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAInRE3q9COZ6v8KnEXz6NwlQPvNSrMvks5rfzbugaJpZM4MKFyK>
.
|
LOL. Yep, I get it. And while I'd love this feature sooner than later, I don't expect you or anyone else to do what I can't (i.e. drop everything else and get this done). If time opens up and this feature hasn't been tackled by someone yet, I'll giver her a go. |
It sounds like a great addition so I am keen to give it a go at least start
on it this week
…On Fri, Feb 24, 2017 at 12:08 PM William Kempf ***@***.***> wrote:
LOL. Yep, I get it. And while I'd love this feature sooner than later, I
don't expect you or anyone else to do what I can't (i.e. drop everything
else and get this done). If time opens up and this feature hasn't been
tackled by someone yet, I'll giver her a go.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1220 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAInRL2tPon7LIfsNy7r9mXdwfC8mpD_ks5rfzihgaJpZM4MKFyK>
.
|
I would split this maybe first adding the Script specific configured as one
PR
…On Fri, Feb 24, 2017 at 12:09 PM Glenn Block ***@***.***> wrote:
It sounds like a great addition so I am keen to give it a go at least
start on it this week
On Fri, Feb 24, 2017 at 12:08 PM William Kempf ***@***.***>
wrote:
LOL. Yep, I get it. And while I'd love this feature sooner than later, I
don't expect you or anyone else to do what I can't (i.e. drop everything
else and get this done). If time opens up and this feature hasn't been
tackled by someone yet, I'll giver her a go.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1220 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAInRL2tPon7LIfsNy7r9mXdwfC8mpD_ks5rfzihgaJpZM4MKFyK>
.
|
I "think" that part is relatively easy (famous last words). The directive
is more effort. We support custom directives, but my sense is there will be
some service I will need injected to register the packages that are
discovered so.
…On Fri, Feb 24, 2017 at 12:11 PM Glenn Block ***@***.***> wrote:
I would split this maybe first adding the Script specific configured as
one PR
On Fri, Feb 24, 2017 at 12:09 PM Glenn Block ***@***.***>
wrote:
It sounds like a great addition so I am keen to give it a go at least
start on it this week
On Fri, Feb 24, 2017 at 12:08 PM William Kempf ***@***.***>
wrote:
LOL. Yep, I get it. And while I'd love this feature sooner than later, I
don't expect you or anyone else to do what I can't (i.e. drop everything
else and get this done). If time opens up and this feature hasn't been
tackled by someone yet, I'll giver her a go.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1220 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAInRL2tPon7LIfsNy7r9mXdwfC8mpD_ks5rfzihgaJpZM4MKFyK>
.
|
Just for reference: fsharp/fslang-suggestions#542 (comment) This is now a very active topic in F# language design. |
Thanks, will check it out!
…On Sat, Feb 25, 2017 at 1:34 AM Steffen Forkmann ***@***.***> wrote:
Just for reference: fsharp/fslang-suggestions#542 (comment)
<fsharp/fslang-suggestions#542 (comment)>
This is now a very active topic in F# language design.
We already have a prototype. Paket is also generating csx files for
loading. It would be cool if we could create something that's working in
both scripting environments
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1220 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAInREj0B7Lg6X-RVLruvnwSfkV0kP8lks5rf_W2gaJpZM4MKFyK>
.
|
Interesting @forki so reading through sounds like |
yes we will make the FSharp.Compiler.Service pluggable. As the following pic shows we already have IDE support: This works since we put it into the FSharp.Compiler.Service, so every tool that uses that will automatically work. So we will see support in VS Code via ionide, in VS, in FAKE, ... A WIP PR can be found at dotnet/fsharp#2483 |
Today we handle loading within scriptcs rather than generating scripts, but
that is an interesting idea.
…On Sat, Feb 25, 2017 at 8:12 AM Steffen Forkmann ***@***.***> wrote:
yes we will make the FSharp.Compiler.Service pluggable.
But tbh Paket is the only tool that you will find that is ready for such
things and allows to generate load scripts (see
https://fsprojects.github.io/Paket/paket-generate-load-scripts.html#Generating-load-scripts-for-all-NuGet-packages).
As I said it already create csx load scripts which loads dlls even from
transitive dependencies.
As the following pic shows we already have IDE support:
https://cloud.githubusercontent.com/assets/57396/23331188/3c1c3d2a-fb61-11e6-8e2e-812268c0fe88.png
This works since we put it into the FSharp.Compiler.Service, so every tool
that uses that will automatically work. So we will see support in VS Code
via ionide, in VS, in FAKE, ...
A WIP PR can be found at dotnet/fsharp#2483
<dotnet/fsharp#2483>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1220 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAInREOFdqbrHEhCederRaEzfiq9Uy7-ks5rgFLwgaJpZM4MKFyK>
.
|
all I'm saying is: it's basically there for you to use ;-) |
Coo. @forki how are you handling semver ranges, is there a way to specify version constraints programatically? Also. of we take a hard dependency on Paket over NuGet, is there anything we lose? (Sorry not very familiar with Paket). |
Of course do we support version ranges and semver. To a much deeper level
than nuget ;-) This technique supports the full power of paket.
Am 25.02.2017 18:16 schrieb "Glenn Block" <notifications@github.com>:
… Coo. @forki <https://github.com/forki> how are you handling semver
ranges, is there a way to specify version constraints programatically?
Also. of we take a hard dependency on Paket over NuGet, is there anything
we lose? (Sorry not very familiar with Paket).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1220 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADgNLhkGsGUdNIQPmhAQPDOJz_foYe_ks5rgGHigaJpZM4MKFyK>
.
|
For the record: I did not suggest to prefer one over the other. In F#
scripting this will be pluggable.
Am 25.02.2017 18:20 schrieb "Steffen Forkmann" <sforkmann@gmail.com>:
Of course do we support version ranges and semver. To a much deeper level
than nuget ;-) This technique supports the full power of paket.
Am 25.02.2017 18:16 schrieb "Glenn Block" <notifications@github.com>:
… Coo. @forki <https://github.com/forki> how are you handling semver
ranges, is there a way to specify version constraints programatically?
Also. of we take a hard dependency on Paket over NuGet, is there anything
we lose? (Sorry not very familiar with Paket).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1220 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADgNLhkGsGUdNIQPmhAQPDOJz_foYe_ks5rgGHigaJpZM4MKFyK>
.
|
I prefer options as well, but maybe we only include Paket out of the box IF it solves all the use cases. Is there a delta, are there things that Paket cannot support for example? Will it work for pure C# script projects? I know we have some support for Paket today in scriptcs, but not sure to what degree. |
@forki in terms of ranges I meant in the declarative syntax? |
You can use everything from https://fsprojects.github.io/Paket/dependencies-file.html so it could look like this:
And Paket will make sure that you get a sound resolution and all packages + transitive dependencies are loaded into the script.
Paket is not bound to F#. Tbh most of paket's users are C# users. |
OK, and is there a delta of capability? Or is it all net positive above what NuGet offers? |
we don't do things like running powershell scripts on install - which we consider wrong |
@forki that's ok, we don't run Powershell scripts either, though we do have the ability to include C# scripts in the package and even to author packages that are pure script. |
For reference see Script Libraries |
we're currently trying to extract that bit into another dll. Maybe we can put that on nuget eventually |
That would be great, but what is the time scale of "eventually" :-) ? |
@forki I am happy initially to take a source dependency if it gets us what we need. |
we started with this 2 days ago. It will take some time to get it really really working. But I guess after we settled on language design we can probably start to push alpha packages. |
Ah ok, so I am not "too late" to the party then.....
…On Sat, Feb 25, 2017 at 9:42 AM Steffen Forkmann ***@***.***> wrote:
we started with this 2 days ago. It will take some time to get it really
really working. But I guess after we settled on language design we can
probably start to push alpha packages.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1220 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAInRI1_u5D1I4lfWr_LVfI6b-Fle_eBks5rgGfpgaJpZM4MKFyK>
.
|
@forki one question I have is what is to gain from generating a load script? Is the main goal to improve startup time? |
Try to reference a meta package like FsLab which consists of many many tools and libraries and creates a full data science environment in your scripting environment. It's important to load all the libs in a sound order otherwise things crash. Paket's heuristic does that for you. |
@glennblock generating load script has been useful to paket users that want to script in F# (or C# but scriptcs already has some support via packages.config as I'm reading) today using nuget packages. That feature was implemented for practical reason and generating scripts sounded like a simple solution to work across all tooling with plain #r / #load directives. In a future release of F# / F# tooling, we'd like to go the extra step of backing this support in a more transparent / out of box way. |
What I'd really like to see is a common approach to this across fsi.exe, scriptcs, csi.exe, etc. |
@adamralph I think currently what paket generates works in scriptcs/csi as well as fsi (for assembly references pulled from nuget dependency graph), it just works based on #r and #load. |
That's why I told you that F# is going to do this right now. So that you
can propose a different way that would work better for you.
Am 25.02.2017 19:08 schrieb "Adam Ralph" <notifications@github.com>:
… What I'd really like to see is a common approach to this across fsi.exe,
scriptcs, csi.exe, etc.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1220 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADgNBzTEGM7rQll8lWwR8AmYKhYUZV9ks5rgG4MgaJpZM4MKFyK>
.
|
Is it worth opening a dialog with Roslyn to see what they would be willing to do in csi.exe? |
BTW, there's open conversation at https://gitter.im/dotnet-scripting/general |
+1
Get Outlook for Android<https://aka.ms/ghei36>
…________________________________
From: Adam Ralph <notifications@github.com>
Sent: Saturday, February 25, 2017 1:08:12 PM
To: scriptcs/scriptcs
Cc: William Kempf; Author
Subject: Re: [scriptcs/scriptcs] Feature Request: NuGet Pragma (#1220)
What I'd really like to see is a common approach to this across fsi.exe, scriptcs, csi.exe, etc.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#1220 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ADRZp0IYw-z_BsEDB0jDC_hSkLnVs0xeks5rgG4MgaJpZM4MKFyK>.
|
@adamralph I thought when we talked to Roslyn we were thinking around overload Sounds like with the F# direction the overloading is of |
@forki, @smoothdeveloper and I have just been chatting on gitter and have agreed to try to work on this together (and we'd welcome your help). I created this branch for us to work out of: https://github.com/scriptcs/scriptcs/tree/paket-directive |
@forki I intend to look at your visualfsharp branch and try to spit the paket logic (part not tied to F# compiler) into at least a file, and maybe a project, then work with @glennblock to add that in their solution (bypass nuget package for now as we are pretty much experimenting on all sides). ScriptCS could be the first scripting environment (after the FAKE for .net core branch) to have inline paket support 😄 |
For scriptcs, having looked over the code a bit, I think this is fairly straight forward to plug in as a POC, but it we will be more work to get the "right" design for scriptcs. We already pick up all #r references in all files as part of our pre-processing step. Right now we do validation at the time we see the directive that the reference is a valid path. So that logic will have to change if the #r starts with "paket:" or whatever. Then I need to change where references are handled so that it can pass them off to paket (using the new code). We agreed that the path of least resistance for the new code would be to add an F# project to scriptcs that will contain this code This would be the MVP The further design would be to make #r extensible and allow plugging in other handlers, but we can worry about that later. |
I've made PR: #1221 first thing needed is to update build scripts to call the paket invocations I'm describing in the PR. @glennblock I've made you a collaborator on my fork so you can push directly there if that's convenient. Currently on F# side, we haven't decided final syntax, but it might be safer for now to use #r with some protocol prefix rather than top level directives: our current code works with |
+1 Really like where this is going. |
One thing I'm not understanding right now is why "paket" appears in the syntax (also true of the F# proposal). I want to use a NuGet package. Why do I care whether Paket is downloading it behind the scenes, or NuGet.Core, or hand-rolled code playing with the HTTP API. Should I expect a specific behaviour because I state "paket"? |
@adamralph I think the idea is you could also have "nuget: " or other handlers. When it relates to big package graph, transitive dependencies, choosing paket or nuget makes a difference, right now the branch is for handling paket case (with paket semantics) but more could be added if needed. It is possible in future we will support If scriptcs decides to rely on paket but hide that to users, you can preprocess directives and pass it to our handler with the correct prefix behind the scene. |
@wekempf making progress here, see screenshots below. If you want to try it out, you can clone the paket-directive branch. You'll need to have MSBuild tools 2015 installed as well. REPLScript |
Is it worth also having a common syntax which doesn't specify a package provider, in which case the script runner uses its default, e.g.
That way we can have a common syntax which works across all runners, without requiring all of them to support |
I've dug through dozens of issues related to this one in the F#, Roslyn, and OmniSharp repos. What is the status of referencing NuGet packages in VSCode with scriptcs? I've seen animated gifs of this working in F#, but does an option currently exist for C# devs? I can't find a wiki page or any blog posts suggesting that it currently is possible, but there are pull requests and dozens of issues on the topic, so I'm hoping someone can speak to the overall status of Intellisense with NuGet packages from VSCode. |
@peder the support for referencing NuGet packages in generalized C# scripts got merged to Omnisharp after work from @seesharper. See this pull-request. Might be what you are looking for? |
RosylynPad has nice syntax to refers nuget package. It would be nice to use this syntax. So we can use this editor to build some scripts. It's lighter than VS. I wish by using this, so the ScriptCS would find the package in nuget's package cache instead of its own package management. Saving some storage, integrating with other package usage. So, instead of |
Using
scriptcs -install
seems a bit of a hack, to be honest. This results in having to maintain multiple files. Cake and other Roslyn based tools allow you to reference NuGet packages within the script itself. It would be great if scriptcs worked the same way.The
#n
directive would install the NuGet package(s) to a local folder (probably packages) and then reference it(them).While making this suggestion, I'll make another. Instead of using a generic "scriptcs_packages.config" file, use a "scriptname_packages.config" file. This would allow your scripts to be in the same directory without having conflicts with the packages used (i.e. each script can use their own NuGet package versions, and restore only has to work with that scripts packages). Or, work more like the new CSPROJ and require version numbers with the
#n
and don't use any config file.The text was updated successfully, but these errors were encountered: