I installed Akka.Cluster with dotnet add package Akka.Cluster and I'm trying to add the reference to an F# Script file.
After a long search I found: The default package location is ~/.nuget/packages on macOS and Linux
I use :
#r #"/Users/{myusername}/.nuget/packages/akka.cluster/1.4.10/lib/netstandard2.0/Akka.Cluster.dll"
In all tutorials I see people use #r #"../packages/ instead of #r #"/Users/{myusername}/.nuget/packages/"
Another alternative I found is using #r #"bin/Debug/netcoreapp3.1/Akkling.Cluster.dll", but I'm not sure this is a good practice.
Is there a shorter version than #r #"/Users/{myusername}/.nuget/packages/... to add packages?
(I know .NET 5 will bring #r "nuget:...")
Related
I'm trying to install some nuget packages using vs code in F# interactive (fsx script). It has worked before because I have successfully installed FSharp.Data, but it seems to not work (anymore).
Following error
No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages, nuget.org (vs code)
Code
open System.IO
open System
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
#r "nuget:System.Data.Linq.dll"
#r "nuget:FSharp.Data.SqlClient.dll"
A related issue says to list the nuget sources through commandline:
Visual Studio 2019 F# NU1101 Unable to find package FSharp.core
When I do this I get a correct response:
So what is going on here?
When You use nuget prefix in the #r directive, you don't have to add ".dll" extension at the end of package name. It is required only when you are referencing local dlls.
https://learn.microsoft.com/en-us/dotnet/fsharp/tools/fsharp-interactive/
I know that I can use #r <pkg> but without a directory to hold a project where should I install /keep the dependencies?
I mean, if I'm using F# I can dotnet add package <pkg> from the project folder but with .fsx I was expecting to not have a "project folder", how to install packages then?
You don't have to worry about downloading and storing the packages somewhere, you can make the interpreter take care of that for you by referencing Nuget packages, not files on your local system. This would look something like this:
#r "nuget: <pkg>"
open Package.Whatever
...
I'm trying to find a simple solution that isn't so much manual work to reference packages. inside a .fsx file.
LinqPad 4 lets me simply add nuget packages
no intellisense or autocompletion
deletes package after download for certain types of packages (templatus for example)
LinqPad 5 beta lets me add nuget packages
deletes package after download for certain types of packages (templatus for example)
with frequent failures (intellisense and compilation)
VS2015 doesn't let you download/install packages for an fsx file (only into projects)
VSCode doesn't let you download/install nuget or paket packages for an fsx file.
So I wind up having to use .fsx in VS2015, while using linqpad to get packages downloaded (which still fails for packages like templatus where it downloads an exe not a dll). Then I have I can reference them as
#I #"..\LINQPad\NuGet.FW46\FParsec\FParsec.1.0.2\lib\net40-client\" // references AppData\local\ ... since . is %localappdata%\TEMP
doesn't match up with the relative pathing for intellisense/autocompletion engine in VSCode so I can't remove VS from the equation.
doesn't work outside of a machine that already has that package in that location
wind up doing a bunch of code that doesn't span .fsx files very well and has to be worked out per package reference
I don't want to create a project. I have a ton of individual scripts that are to be individually maintained and usable by others on-demand.
Is there an IDE (or fix/extension for one of these mentioned) that will give me intellisense, autocomplete, and package management for F# .fsx files that can work easily from user to user, machine to machine?
The Ionide plugins for VsCode and Atom have the functionality you're looking for
VsCode Instructions
Use the command palette to install the Ionide extensions ionide-fsharp and ionide-paket
You'll need to add your F# installation to your PATH
(on windows Rapid Enivornment Editor is my goto for PATH editing)
For F# 4.0 add C:\Program Files (x86)\Microsoft SDKs\F#\4.0\Framework\v4.0
Open the work folder that will hold your .fsx files
Executing paket commands through the command palette will be your primary interface for working with nuget packages
make a new .fsx file, (I recommend using the Advanced New File extension over the standard VsCode method)
The first step is to run paket init which is necessary to use paket to manage your packages
If you click the open button on the notification popups you can view the the output from paket in a side panel
After using the add nuget package command and entering extcorefor the package you should see the work tree
updated to
Then all you need to do is reference the package in the script and you'll get the auto-completion you're looking for
As of F# 5.0 you can now use the #r "nuget: Package" (ref):
#r "nuget: Newtonsoft.Json"
// Optionally, specify a version explicitly
// #r "nuget: Newtonsoft.Json,11.0.1"
open Newtonsoft.Json
let o = {| X = 2; Y = "Hello" |}
printfn "%s" (JsonConvert.SerializeObject o)
I am currently learning F# and working through the samples on tryfsharp.org. I am using the Mono F# on a Mac.The script begins as follows:
#r "MathNet.Numerics.dll"
open MathNet.Numerics
open System.Numerics
When starting the script I get the following error message:
/Users/benjamin/Desktop/Kalman/kalman.fsx(1,1): error FS0078: Unable to find the file '
MathNet.Numerics.dll' in any of
/Library/Frameworks/Mono.framework/Versions/3.0.12/lib/mono/4.5
/Users/benjamin/Desktop/Kalman
/Library/Frameworks/Mono.framework/Versions/3.0.12/lib/m
I do not know, where to find that DLL or how to install it.
You should just be able to use nuget to get that library.
http://nuget.org/packages/MathNet.Numerics
See here to install nuget:
http://docs.nuget.org/docs/start-here/nuget-faq
I was hoping to upgrade to F# 3.0 but I can't find either a packaged F# 3.0 compiler on Microsoft site, nor if there is an express version to use. Is it possible to install F# 3.0 for use from the command line or a simple IDE and if so, how?
The standalone version of F# is not available yet, but F# tools for Visual Studio Express have been released just 2 days ago, so you can get F# 3.0 for free.
Announcing F# Tools for Visual Studio Express 2012 for Web!
As far as I know, there are definitely plans for open-source release (that can be integrated with MonoDevelop) and it would make sense to have a stand-alone installer too (otherwise you could still just compile the open-source release), but I don't think there are specific dates for that.
The easiest way I've got it to run:
http://www.heartysoft.com/build-fsharp-3-on-build-server-without-vs
Essentially using the direct download link on the Web PI tools.
I have successfully make a standalone F# 3.0 works without Visual Studio 2012.
First, find a workstation with F# 3.0 installed. (source)
Duplicate all the things to destination workstation.
-> C:\Program Files (x86)\Microsoft SDKs\F#
-> C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp
-> C:\Windows\Microsoft.NET\assembly\GAC_MSIL\FSharp*
Install .NET 4.5 at destination.
Export all the registry item with FSC.exe string to destination.
Export all the registry item with FSharp string to destination.
f# 3.0 registry.rar
if you don't know how to export the registry items, please download this file and use powershell to import all this .reg file.
PowerShell script: (put the .reg files into c:\xxx suppossedly )
cd c:\xxx
dir *.reg | %{ ('reg import "' + $_.Name + '"') | cmd }
I'm assuming most of you seeking an answer to this question by now probably wouldn't mind the most recent version, which is 4.0. You can download this as a standalone at F# 4.0 . This does not include the supporting assemblies and will fail by itself. So you'll also have to download and install the Microsoft Build Tools 2015 . Should be all set to go from there, no installing the mega-massive visual studio. Of course if you need an IDE you'll need to seek out a free one.
You can use Nuget CLI to install the F# Compiler Tools without relying on Visual Studio. As a plus, this procedure does not require admin rights.
Visit nuget.org/downloads and download the latest nuget.exe file.
Instruct your browser to save the file to a folder of your choice.
Add the folder where you placed nuget.exe to your PATH environment variable to use the CLI tool from anywhere.
Open a command prompt and navigate to the folder where you want to install F# Tools.
Run "nuget install FSharp.Compiler.Tools -Version {version}", where {version} is replaced with a version from https://www.nuget.org/packages/FSharp.Compiler.Tools
Add the 'tools' directory to your PATH Environment Variable and then you will be able to use fsc and fsi from the command line.
There is not currently a standalone version of F# 3.0. However, one has been promised
I run F# 3.0 from the cygwin command line on Windows 7. You need to know a little about Linux/Unix to use cygwin, but the basics are not too difficult. You need the basic cygwin shell (command interpreter) and an editor. I am used to vi, so cygwin has vim (there exists a nice F# syntax color addon to vim).
You need to:
Install visual studio in order to get F#
in /users/myname/.bashrc add the location of Fsc.exe, which in my case is
/cygdrive/c/Program Files (x86)/Microsoft SDKs/F#/3.0/Framework/v4.0
to your PATH.