question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet scripting / fsc compilation of .fsx scripts should package all the runtime dependencies along the compiled .exe

See original GitHub issue

fsc support for compiling .fsx files could be improved by packaging all the runtime dependencies in the output folder, next to the compiled .exe.

Describe the solution you’d like

I’d like this to be the default behaviour, but since it would be a change of behaviour, maybe it would require a flag (--copy-runtime-dependencies-to-output-folder ?)

It should take care of those constructs:

  • DependencyManager that are pulled through #r "extension: " mechanism
  • vanilla #r "Assembly" directives
  • #load “otherscript.fsx”
  • more generally, all the HashDirective constructs that F# supports in scripts

Describe alternatives you’ve considered

Alternative is to make a new compiler out of FCS, that would do that, but it seems more cohesive to expand the support for compiling .fsx that is already implemented in fsc

Additional context

Related to https://github.com/dotnet/fsharp/issues/13236#issuecomment-1162153774 Related to https://github.com/dotnet/interactive

cc: @KevinRansom @jonsequitur

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:15 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
KevinRansomcommented, Jun 28, 2022

@MecuSorin , I believe that what @smoothdeveloper would like to see is a developer experience for sompiling scripts that is as simple as the old desktop compile experience

fsc program.fsx

On the desktop framework this built an .exe that ran. In the cross platform multi-assembly world we now live in, the project file is pretty much essential. However, because #r “nuget: blah” which is valid .fsx syntax and thus can be compiled with F# compiler; the dependencies retrieved using it are not visible to the dotnet build and pack processes. They can of course be easily added to the project file for compile, but it is an extra manual step. What I believe @smoothdeveloper is really asking for is a mechanism that simplifies compiling and deploying F# scripts that have complex dependencies.

This isn’t a scenario we have spent much time on thinking through, but is certainly quite valuable to script developers. Any change we make, would most likely involve teaching dotnet build to understand how to access the results of the #r nuget action.

1reaction
kant2002commented, Sep 23, 2022

Most probably I want to have dotnet publish myscript.fsx, because this is ultimately publishing with all parameters which dotnet publish can provide. I imaging if we can teach dotnet-publish to handle .fsx files as projects. If think this through, IronPython can benefit from this too, as other languages. but this way may require some form of support from dotnet SDK for scripting environments which maybe accepted or not.

As a practical way to do it, I create prototype tool which I share in #13961 . I collect all references and handle other directives, similar to what @jonsequitur seems to be doing and pass additional arguments to dotnet publish. Would be curious to know how they do it.

seems to be whole scope of work is relatively small, but packaging solution and property land it inside existing tooling is complicated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

F# Interactive (dotnet) Reference
Learn how F# Interactive (dotnet fsi) is used to run F# code ... Once compiled, you can reference it in a file called...
Read more >
f# how can i compile and then release a file .fsx
Instead of compiling source code and then later running the compiled assembly, you can just run fsi.exe and specify the filename of the...
Read more >
Compiling and Executing F# Dynamically at Runtime
First lets define what I mean by compile and run F# at runtime - in my case I want to load a script...
Read more >
What dependencies are required to run a compiled script
Hi, Using Visual Studio 2010 and the Ranorex API, I'm creating a console application that gets compiled into an EXE that I can...
Read more >
F# Interactive Integration
Paket implements this extension mechanism to hook same power as paket.dependencies file right inside .fsx scripts. Making sure paket.exe is found. The extension ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found