VS2022 C#(.NET 6) deps.json, runtimeconfig.json 以及 dll 關係

VS2022 C#(.NET 6) deps.json, runtimeconfig.json 以及 dll 關係

VS2022 C#(.NET 6) deps.json, runtimeconfig.json 以及 dll 關係


資料來源: https://www.796t.com/content/1575738302.html

https://www.796t.com/content/1575738302.html


01. runtimeconfig.json : 定義該執行程式必要的 frameworks(runtimeOptions) 版本


實際範例 (該檔說明 本執行檔 使用 .net6 Runtime)

{
  "runtimeOptions": {
    "tfm": "net6.0",
    "frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "6.0.0"
      },
      {
        "name": "Microsoft.WindowsDesktop.App",
        "version": "6.0.0"
      }
    ],
    "configProperties": {
      "System.Reflection.Metadata.MetadataUpdater.IsSupported": false
    }
  }
}


02. deps.json : 定義該執行程式必要的 DLL檔案跟執行檔的相對路徑關係 

    如果不要 打包/使用 該檔案,最簡單的方法就是將所有DLL放在執行檔同層的目錄下 (ps.所以當從NuGet下載元件具有跨平台特性時,該檔案就特別重要)


實際範例 (該檔說明 模組SQLite 的 SQLite.Interop.dll為跨平台元件)

{
  "runtimeTarget": {
    "name": ".NETCoreApp,Version=v6.0",
    "signature": ""
  },
  "compilationOptions": {},
  "targets": {
    ".NETCoreApp,Version=v6.0": {
      "VPOS/1.0.0": {
        "dependencies": {
          "Dapper": "2.0.123",
          "System.Data.SQLite.Core": "1.0.116",
          "Vteam_Dialog": "1.0.0",
          "Vteam_UserControl": "1.0.0"
        },
        "runtime": {
          "VPOS.dll": {}
        }
      },
      "Dapper/2.0.123": {
        "runtime": {
          "lib/net5.0/Dapper.dll": {
            "assemblyVersion": "2.0.0.0",
            "fileVersion": "2.0.123.33578"
          }
        }
      },
      "Stub.System.Data.SQLite.Core.NetStandard/1.0.116": {
        "runtime": {
          "lib/netstandard2.1/System.Data.SQLite.dll": {
            "assemblyVersion": "1.0.116.0",
            "fileVersion": "1.0.116.0"
          }
        },
        "runtimeTargets": {
          "runtimes/linux-x64/native/SQLite.Interop.dll": {
            "rid": "linux-x64",
            "assetType": "native",
            "fileVersion": "0.0.0.0"
          },
          "runtimes/osx-x64/native/SQLite.Interop.dll": {
            "rid": "osx-x64",
            "assetType": "native",
            "fileVersion": "0.0.0.0"
          },
          "runtimes/win-x64/native/SQLite.Interop.dll": {
            "rid": "win-x64",
            "assetType": "native",
            "fileVersion": "1.0.116.0"
          },
          "runtimes/win-x86/native/SQLite.Interop.dll": {
            "rid": "win-x86",
            "assetType": "native",
            "fileVersion": "1.0.116.0"
          }
        }
      },
      "System.Data.SQLite.Core/1.0.116": {
        "dependencies": {
          "Stub.System.Data.SQLite.Core.NetStandard": "1.0.116"
        }
      },
      "Vteam_Dialog/1.0.0": {
        "dependencies": {
          "Vteam_UserControl": "1.0.0"
        },
        "runtime": {
          "Vteam_Dialog.dll": {}
        }
      },
      "Vteam_UserControl/1.0.0": {
        "runtime": {
          "Vteam_UserControl.dll": {}
        }
      }
    }
  },
  "libraries": {
    "VPOS/1.0.0": {
      "type": "project",
      "serviceable": false,
      "sha512": ""
    },
    "Dapper/2.0.123": {
      "type": "package",
      "serviceable": true,
      "sha512": "sha512-RDFF4rBLLmbpi6pwkY7q/M6UXHRJEOerplDGE5jwEkP/JGJnBauAClYavNKJPW1yOTWRPIyfj4is3EaJxQXILQ==",
      "path": "dapper/2.0.123",
      "hashPath": "dapper.2.0.123.nupkg.sha512"
    },
    "Stub.System.Data.SQLite.Core.NetStandard/1.0.116": {
      "type": "package",
      "serviceable": true,
      "sha512": "sha512-VEe/vzvn2ECKovtyb+nf8fsnNQ4EYOUms7gnp9729NN7FSR/0v/uVoBDO7DETzV7YCquRVwRnSnYuoOwAoTEKA==",
      "path": "stub.system.data.sqlite.core.netstandard/1.0.116",
      "hashPath": "stub.system.data.sqlite.core.netstandard.1.0.116.nupkg.sha512"
    },
    "System.Data.SQLite.Core/1.0.116": {
      "type": "package",
      "serviceable": true,
      "sha512": "sha512-djwmo97syWCpUPJbDS0e2qUFUa8cDLeIfMotVkaRkAC5gpfBSZLMzvoLkLp1prY8waAuH1jEC3wcB2ymVVQWtA==",
      "path": "system.data.sqlite.core/1.0.116",
      "hashPath": "system.data.sqlite.core.1.0.116.nupkg.sha512"
    },
    "Vteam_Dialog/1.0.0": {
      "type": "project",
      "serviceable": false,
      "sha512": ""
    },
    "Vteam_UserControl/1.0.0": {
      "type": "project",
      "serviceable": false,
      "sha512": ""
    }
  }
}




發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *