fsprojects / FSharp.Configuration

The FSharp.Configuration project contains type providers for the configuration of .NET projects.
http://fsprojects.github.io/FSharp.Configuration/
Other
114 stars 63 forks source link

AppSettings - scripts & redirection #86

Open isaacabraham opened 8 years ago

isaacabraham commented 8 years ago

I have an .fs file which references the AppSettings provider. If I #load this file from a script, the code does not compile (I imagine because the TP is trying to locate the properties from FSI's app.config). Is there any way around this? The redirection support is only for runtime, not design time.

smoothdeveloper commented 8 years ago

@isaacabraham I think the provider was changed recently, can you check this change: https://github.com/fsprojects/FSharp.Configuration/commit/d88444a44d11aae8f12b65fc2758d34aa0d46a47 or this part of the documentation: http://fsprojects.github.io/FSharp.Configuration/AppSettingsProvider.html#Using-AppSettingsProvider-in-fsx-script

isaacabraham commented 8 years ago

Yes - that's referring rather to runtime redirection though rather than compile-time.

smoothdeveloper commented 8 years ago

@isaacabraham can you try

let [<Literal>] appSettingsPath = __SOURCE_DIRECTORY__ + "/app.config"
type Config = FSharp.Configuration.AppSettings<appSettingsPath>
panesofglass commented 6 years ago

@isaacabraham in case you didn't figure this out, you have to set both the full path and then SelectExecutableFile, e.g.

// Script name is Script1.fsx
let [<Literal>] appSettingsPath = __SOURCE_DIRECTORY__ + "/Script1.fsx.config"
type Config = FSharp.Configuration.AppSettings<appSettingsPath>
let [<Literal>] executableFile = __SOURCE_DIRECTORY__ + "/Script1.fsx"
Config.SelectExecutableFile executableFile