为什么 runtimeconfig.json 包含 includedFrameworks 而不是框架?

Why dose runtimeconfig.json contain includedFrameworks instead of frameworks?

您好,

我有一个像这样发布的 AspNet Core 应用程序:

dotnet publish -c release MyApplication.csproj

问题是,生成的 MyApplication.runtimeconfig.json 剂量包含 includedFrameworks 标签而不是 frameworks

这是我得到的:

{
  "runtimeOptions": {
    "tfm": "net5.0",
    "includedFrameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "5.0.10"
      },
      {
        "name": "Microsoft.AspNetCore.App",
        "version": "5.0.10"
      }
    ],
    "configProperties": {
      "System.GC.Server": true,
      "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
    }
  }
}

但我希望:

{
  "runtimeOptions": {
    "tfm": "net5.0",
    "frameworks": [         // <-------------
      {
        "name": "Microsoft.NETCore.App",
        "version": "5.0.10"
      },
      {
        "name": "Microsoft.AspNetCore.App",
        "version": "5.0.10"
      }
    ],
    "configProperties": {
      "System.GC.Server": true,
      "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
    }
  }
}

谁能告诉我为什么 dotnet 这样做,bzw 如何以正确的方式生成它?

感谢您的帮助!

解决方法是添加以下参数:

dotnet publish -c Release -p:UseAppHost=false --self-contained false

在我的例子中,应用程序托管在 IIS 中。