Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

F# for scripting: location of script file

In an F# script file (.fsx), how can I determine the location of the .fsx file currently executing? I'd like to resolve paths relative to it.

I tried Assembly.GetExecutingAssembly().CodeBase but that doesn't work in a "dynamic assembly", apparently.

like image 908
Eamon Nerbonne Avatar asked Feb 01 '11 09:02

Eamon Nerbonne


1 Answers

extract from F# spec:

__SOURCE_DIRECTORY__ - Replaced by a literal verbatim string that specifies the name of the directory that contains the current file, for example, C:\source. The name of the current file is determined by the most recent line directive in the file. If no line directive has been given, the name is determined by that given to the command-line compiler in combination with System.IO.Path.GetFullPath.

__SOURCE_FILE__ - Replaced by a literal verbatim string that contains the name of the current file, for example, file.fs

like image 114
desco Avatar answered Nov 07 '22 10:11

desco