我試圖將連接字符串和憑據數據存儲在.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