.runtimeconfig.dev.json 中的 configProperties 會覆寫 .runtimeconfig.json 中的設定

如果應用程式在 configProperties.runtimeconfig.json中都定義相同的執行時.runtimeconfig.dev.json鍵,則該.runtimeconfig.dev.json值優先。

所推出的版本

.NET 11 預覽版 6

以前的行為

先前,對於重複的 configProperties 金鑰,.runtimeconfig.json 的優先順序高於 .runtimeconfig.dev.json

例如:

// 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 中的開發時覆寫,對於重複的 configProperties 金鑰,.runtimeconfig.dev.json 的優先順序高於 .runtimeconfig.json

以相同的範例為例,執行階段現在使用 System.GC.Concurrent: false

破壞性變更的類型

此變更為行為變更

變更原因

此變更使開發者能在開發過程中覆寫生產設定,而無需修改生產設定檔。

欲了解更多資訊,請參閱 dotnet/runtime#126606

為了讓正式環境中的行為可預期,僅將開發階段的覆寫設定放在 .runtimeconfig.dev.json 中。

為避免在開發時發生覆寫,請從 .runtimeconfig.dev.json 移除重複的金鑰。

受影響的 API

None.

另請參閱