I have a solution with multiple F# projects. I can easily reference between projects using relative path.
However, if I want to use that project in a .fsx file in another project, I have to provide the absolute path to the corresponding dll file, which is quite inconvenient. I notice that F# Powerpack could be referenced in F# Interactive in a convenient way:
#r "FSharp.Powerpack.dll"
How can I register a path to F# Interactive permanently or reference a project to use in F# Interactive without providing the absolute path?
You can use #I
to set the directory path once. Then use #r
from there on with just the file name. In the case of PowerPack, it's likely in the GAC, so only the assembly name is needed.
As Daniel pointed out, F# PowerPack can be referenced using the short name, because it is installed to the GAC (Global Assembly Cache). This requires the assembly to be signed and I generally wouldn't use it often for non-system libraries.
If the location of your assembly is always the same, relatively to the F# script file (ie if the script file is a part of the project), then you can use a relative path:
#r @"..\Library\bin\Debug\Library.dll"
Another alternative is to create some custom folder and tell F# Interactive to search for assemblies in that folder. This can be done by adding a command line argument -I:"C:\\your\\folder"
to the F# Interactive process (In Visual Studio, go to "Options", then "F# Tools" and change "F# Interactive options").
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.