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)
Related
What files must I add while building the installation file in Rad Studio using Advanced installer? When I chose the project file, I launched the file created with Advanced Installer, but it says that:
file_name.bpl missing
What should I do ?
If you don't build with runtime packages (Project->Options->Packages->Runtime packages->Link with runtime packages is False), then you only have to distribute your application executable (.exe).
If you build with runtime packages (Project->Options->Packages->Runtime packages->Link with runtime packages is True), you have to include those packages when you distribute your application executable (.exe). This requires at a minimum that you include the VCL and RTL packages (vclXXX.bpl and rtlXXX.bpl, where XXX depends on the specific version of RAD Studio that you're using).
Depending on what your application does, you may also have to include other runtime packages in your installer. You can find the list of packages that your application needs by looking at the runtime package list in Project->Options->Packages->Runtime Packages->Runtime packages (click the ... button to open the dialog).
For more information, see the RAD Studio documentation topic Deciding Which Runtime Packages to Use.
You should be able to find a list of names of the packages used from the menu at Project/Information for YourApplication This list should be available once the project has successfully compiled and linked.
Even more useful may be the Project/Deployment menu item. This item is designed to actually deploy your application and its files to a remote machine using paserver, and perhaps could be used to do that in the process of making your installation file.
However, the big advantage of Project/Deployment is that it lists not only the name of each file, but also the Directory where that file can be found.
It looks to me like there may be files under Project/Deployment, such as localization language files, that might not always be needed, so I would cross-check Project/Deployment (which shows the Directory) with the Project/Information for YourApplication list. However, Project/Deployment is where I would look to find the directory where the missing file_name.bpl that Advanced Installer needs can be found.
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've written some Delphi code I would like to share on GitHub. All code is contained in runtime and designtime packages as required. There are many "Project Options" to set for each project. (Output directories, search paths, compilation options, etc.) I've managed to find some default options that work well for my situation but reading other Q&As here it's clear there are multiple ways of working.
What project options should be used to allow the open source packages to easily be incorporated into individual projects?
I've recently started using NodeJS. The NPM package manager makes it super easy to use third-party packages in a project. Packages are installed with one simple command on the command line. Packages will automatically install any required dependencies.
PS: Feel free to edit this question if you would like to add extra things to consider.
Let's say you have this structure
MyComponent
Packages
DelphiXE7
Package2.dpr
source
bin
Delphi XE7
then set
Search Path
..\..\..\source
Unit output directory
..\..\..\bin\Delphi XE7\$(Platform)\$(Config)
After compilation for all supported platforms and both Release and Debug you will have this structure in the bin directory
MyComponent
Packages
DelphiXE7
Package2.dpr
source
bin
Delphi XE7
Android
Release
Debug
Win32
Release
Debug
Win64
Release
Debug
For installation you have to setup some path inside the IDE.
Environment
MYCOMPONENT => [root path to the files]
Library
Repeat that for all supported platforms
Library Path
$(MYCOMPONENT)\bin\Delphi XE7\$(Platform)\Release
Search Path
$(MYCOMPONENT)\source
Debug-DCU-Path
$(MYCOMPONENT)\bin\Delphi XE7\$(Platform)\Debug
If there are some language related units there is also a place to add (see Library - translated)
This ensures, that you have full debug feature (with Use Debug-DCU option set) and on release you have no debug code in your application.
Just a sidenote on libraries you should not want to install because you only use them in some projects.
Simply use the Optionset combined with a environment variable.
Here my SuperObject.optionset ($(USRLIB) points to a directory, where I collect all common used source code. And $(USRLIB)\ext is the place for all of the external libraries).
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DCC_UnitSearchPath>$(USRLIB)\ext\superobject;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
</PropertyGroup>
<ProjectExtensions>
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
<Borland.ProjectType>OptionSet</Borland.ProjectType>
<BorlandProject>
<Delphi.Personality/>
</BorlandProject>
<ProjectFileVersion>12</ProjectFileVersion>
</ProjectExtensions>
</Project>
To use the superobject library I simply add the optionset to the project (right mouse click on build configuration) and everything is fine.
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.