c# - YAML 文件未添加到构建时的 bin\debug (.NET Core)
问题描述
我的项目根目录中有一个 _config.yml YAML 文件。
我在 Startup.cs 中做:
var builder = new ConfigurationBuilder()
.SetBasePath(AppContext.BaseDirectory)
.AddYamlFile("_config.yml");
Configuration = builder.Build();
当我构建并运行项目时,出现以下错误:
System.IO.FileNotFoundException: The configuration file '_config.yml' was not found and is not optional. The physical path is 'C:\Users\user\OneDrive\Documenten\Descent.Bot\bin\Debug\n
etcoreapp3.1\_config.yml'.
不应该通过构建项目自动添加 YAML 文件bin\Debug
吗?有bin\Debug
没有我自己手动添加 YAML 文件的方法?
解决方案
您可以在 Visual Studio 中右键单击该文件,然后单击属性。在那里您将看到将文件复制到输出目录的选项。
在后台,Visual Studio 正在 .csproj 中创建一个 None 来处理流程
推荐阅读
- python - 获取 HKEY 常量根目录中的注册表项
- php - 完整性约束违规:1451 无法删除或更新父行:外键
- c# - 将 WasapiLoopbackCapture 缓冲区转换为 PCM
- javascript - 列出通过数据绑定搜索的 td 值中的特定数据
- windows - 关于多级目录结构中DACL继承的问题
- wordpress - 如何将最近五年添加到 cf7 下拉菜单?
- ios - 在 Xcode 中手动创建配置文件
- python - 如何在 roi 上使用 opencv 函数
- typescript - Express 的压缩不适用于 EJS
- python - 如何将 PIL 图像转换为字符串,然后将其转换回 PIL 图像?无需将其保存到新文件即可完成转换