简体   繁体   English

如何让 NCrunch 使用特定的 appsettings.json 文件?

[英]How to make NCrunch use specific appsettings.json file?

There are some API tests in my solution that require setting from appsettings.json file.我的解决方案中有一些 API 测试需要从appsettings.json文件进行设置。 Local environment differs from DEV/PROD.本地环境不同于 DEV/PROD。 Because of that I have main appsettings.json config and additional appsettings.Development.json with some settings specific for dev machine.因此,我有主要的appsettings.json配置和其他appsettings.Development.json以及一些特定于开发机器的设置。

NCrunch was working fine grabbing settings from the Development config file until new configs were added:在添加新配置之前,NCrunch 可以很好地从开发配置文件中抓取设置:

appsettings.json
    appsettings.Development.json
    appsettings.Local.json
    appsettings.Production.json

I updated launchSettings.json file to use Local config.我更新launchSettings.json文件以使用本地配置。 It works fine when I run it from VS, but NCrunch still uses Development.当我从 VS 运行它时它工作正常,但 NCrunch 仍然使用开发。 Is there any way to make it use Local?有没有办法让它使用本地?

Not tried this, but it should get you close.没有试过这个,但它应该让你接近。

  1. In Visual Studio, go to Extensions->NCrunch->Configuration在 Visual Studio 中,go 到 Extensions->NCrunch->Configuration
  2. Select your-project - Shared Settings (or other scope, whatever you prefer) Select 您的项目 - 共享设置(或其他 scope,无论您喜欢什么)
  3. In the bottom pane in the 'General' expander, select 'Custom environment variables'.在“常规”扩展器的底部窗格中,select“自定义环境变量”。
  4. Add a key / value as ASPNETCORE_ENVIRONMENT and Development.添加一个键/值作为 ASPNETCORE_ENVIRONMENT 和 Development。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 功能标志 - 如何将 appsettings.json 替换为另一个 json 文件 - Feature flags - How to substitute appsettings.json for another json file Asp.Net 核心剃刀 - 如何在 _Layout.cshtml 文件中使用 appsettings.json 值? - Asp.Net core razor - how to use appsettings.json value in _Layout.cshtml file? 如何使 appsettings.json 配置在项目中而不是 bin 文件夹中? - How to make appsettings.json is configured in project instead of bin folder? mvc 核心 2.0,如何通过配置使用 appSettings.json 文件 - mvc core 2.0, how to use an appSettings.json file via configuration 如何使用POCO对象访问appsettings.json文件(ASP.NET 5)中的选项数组 - How to use a POCO object to access an array of options in the appsettings.json file (ASP.NET 5) Asp.net core 6 Program.cs文件中appsettings.json的使用方法 - How to use appsettings.json in Asp.net core 6 Program.cs file 如何将 appsettings.json 中的日志级别参数用于 Serilog? - How to use Logging level parameter from appsettings.json for Serilog? 如何使用发布配置文件更改值是 appsettings.json - How to use publish profile to change a value is appsettings.json 如何在另一个项目或类库中使用 appsettings.json - How to use appsettings.json in another project or class library 如何将选项模式用于 appsettings.json 复数数组 - How to use Options pattern for appsettings.json complex array
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM