# F# Scripting Tips and Tricks ## Getting Command Line Arguments You can either use the `fsi` object and `fsi.CommandLineArgs`, or the .NET's `System.Environment.GetCommandLineArgs()`. ## Script File Paths Is an F# scripting feature that is used to identify the location and line numbers of script files. All identifiers take the [[Line Compiler Directive in FSharp]] into account. ```fsharp let printSourceLocation() = printfn "Line: %s" __LINE__ printfn "Source Directory: %s" __SOURCE_DIRECTORY__ printfn "Source File: %s" __SOURCE_FILE__ printSourceLocation() ``` Output: ``` Line: 4 Source Directory: C:\Users\username\Documents\Visual Studio 2017\Projects\SourceInfo\SourceInfo Source File: Program.fs ``` ## Referencing Nuget Packages ```fsharp #r "nuget: Suave" ``` This feature is known as Package References and is new in F# 5. To specify a version, use ```fsharp #r "nuget: NodaTime, 3.1.*" ``` To reference a package from a custom package source you need to run ```fsharp #i "nuget: https://nuget.nikolamilekic.com/index.json" ``` or in the alternative you can place a `NuGet.config` file next to the script with the following: ```xml <?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="Sleet" value="https://nuget.nikolamilekic.com/index.json" /> </packageSources> </configuration> ```