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

Possibility to override used *.config file #79

Closed Thorium closed 8 years ago

Thorium commented 8 years ago

I'm trying to run AppSetting provider (the NuGet package version) from FShap Interactive (version 14.0.23020.0).

I try to give the path in any format:

type Settings = FSharp.Configuration.AppSettings<__SOURCE_DIRECTORY__ + @"/app.config">
type Settings = FSharp.Configuration.AppSettings<__SOURCE_DIRECTORY__ + @"\app.config">
type Settings = FSharp.Configuration.AppSettings<"app.config">

(I was hoping to use the first one to work on both .NET and Mono...) Visual Studio Intellisense works fine. Settings.ConfigFileName gives the right file name. But trying to get or set the actual values (Settings.MyThingHere) from F# Interactive will raise an exception. So none of these works. they raise:

 System.Collections.Generic.KeyNotFoundException: Cannot find name RuntimeDBConnectionString in <appSettings> section of config file.
   at FSharp.Configuration.AppSettingsTypeProvider.getConfigValue(String key) in d:\git\FSharp.Configuration\src\FSharp.Configuration\AppSettingsProvider.fs:line 21
   at <StartupCode$FSI_0004>.$FSI_0004.main@() in C:\git\myproject\MyScript.fsx:line 45

I'm trying to debug what happens here, and I think it is trying in runtime use Fsi.exe.config instead of the file I have given. getConfig().AppSettings.Settings.[key] fails as AppSettings Count is zero.

Thorium commented 8 years ago

appsettings

Thorium commented 8 years ago

So I wish that instead of ConfigurationManager.OpenExeConfiguration there would be a way to use either the initial configuration file or runtime defined file. I was thinking that this could be easy way to create scripts to manipulate *.config files.

Thorium commented 8 years ago

This is actually duplicate for #16