.runtimeconfig.dev.json 中的 configProperties 替代 .runtimeconfig.json

如果应用在两者configProperties.runtimeconfig.json中都定义了相同的运行时.runtimeconfig.dev.json键,则.runtimeconfig.dev.json该值优先。

引入的版本

.NET 11

以前的行为

以前,出现重复的 .runtimeconfig.json 键时,.runtimeconfig.dev.json 的优先级高于 configProperties。

例如:

// app.runtimeconfig.json
{
  "runtimeOptions": {
    "configProperties": {
      "System.GC.Concurrent": true
    }
  }
}
// app.runtimeconfig.dev.json
{
  "runtimeOptions": {
    "configProperties": {
      "System.GC.Concurrent": false
    }
  }
}

使用此配置时,运行时使用了 System.GC.Concurrent: true。

新行为

为支持 .NET 11 中的开发时覆盖,对于重复的 .runtimeconfig.dev.json 键,.runtimeconfig.json 优先于 configProperties。

使用同一示例,运行时现在使用 System.GC.Concurrent: false。

破坏性变更的类型

此更改为行为更改。

更改原因

通过此更改,开发人员可以在开发过程中重写生产设置,而无需修改生产配置文件。

有关详细信息,请参阅 dotnet/runtime#126606。

为确保生产环境中的行为可预测,仅将开发时覆盖项放置在 .runtimeconfig.dev.json 中。

若要防止开发时重写,请从 .runtimeconfig.dev.json中删除重复键。

受影响的 API

None.

另见