我试图将连接字符串和凭据数据存储在.config
文件中。我无法将连接/凭证的配置推送到回购站;该配置将位于安全的已同步文件夹中,该文件夹的主目录不是而是。我引用的配置文件需要在项目的主目录中吗?
我可以存储的连接/在app.config
文件中的主目录,并与FSharp.Configuration
库访问它的凭据:
type connection = AppSettings<"app.config">
但如果我尝试在不同的目录访问配置
open System.IO
open FSharp.Configuration
let baseDirectory = __SOURCE_DIRECTORY__
let baseDirectory' = Directory.GetParent(baseDirectory)
let configPath = "Tresor\app.config"
let fullConfigPath = Path.Combine(baseDirectory'.FullName, configPath)
type Settings = AppSettings<fullConfigPath>
的fullConfigPath
错误出与
This is not a valid constant expression or custom attribute value.
即使我尝试使用YAML类型提供
let yamlPath = "Tresor\Config.yaml"
let fullYamlPath = Path.Combine(baseDirectory'.FullName, yamlPath)
type Config = YamlConfig<FilePath = fullYamlPath>
我得到了fullYamlPath
类似的错误。
是否有原因我无法访问主目录之外的文件?我正确构建文件路径吗?
类型提供者的参数(在你的情况下,'FilePath')需要是编译时常量(所以要么是硬编码的字符串,要么是字符串文字)。 – scrwtp