Question

The fsharp spec, defines __SOURCE_DIRECTORY__ as: "A literal verbatim string that specifies the name of the directory that contains the current file..."

However, when I query it in fsi, I get a different directory.

Specifically, I am expecting: z:\desktop\dropbox\dev\xenomorph

whereas I am actually getting: c:\Users\Vij\AppData\Local\Temp

I am using visual studio 13 on a windows 8 virtual machine created in Parallels 9 on Mac OS 10.9.

Any ideas what's happening here? More importantly, how could I set the value to the one that I expect. (My current situation means that any #r directives involving "../" have to be manually hard-coded.)

thanks Vijesh

Was it helpful?

Solution

Any ideas what's happening here?

If you manually enter in the VS FSI window

printfn __SOURCE_DIRECTORY__;;

you will get something like

C:\...

If you enter in an fsx file and then send to FSI

printfn __SOURCE_DIRECTORY__;;

you will get the directory where the fsx file is located like

E:\Projects...

Note: I did these examples using VS 2010 on Windows 7.

See my __SOURCE_DIRECTORY__ notes

How could I set the value to the one that I expect?

There has been a change between VS 2010 and VS 2012 when using relative directories, but if it works for VS 2010 it works for VS2012 but not the other way around.

In our project we used an initialization.fsx file which correctly uses #I and #r. e.g.

#I @".\..\FSharpx.Books.AutomatedReasoning\bin\Debug"
#r @"FSharpx.Books.AutomatedReasoning.dll"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top