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": ""
}
}
}
2 thoughts on “VS2022 C#(.NET 6) deps.json, runtimeconfig.json 以及 dll 關係”
C#.NET 知識高裝檢 – .pdb 檔、編譯最佳化與偵錯
https://blog.darkthread.net/blog/about-dotnet-pdb/
發現我對 PDB 檔的知識有點模糊過時,特舉辦知識高裝檢。
01. pdb 檔的主要用途為何?
PDB 提供編譯後程式與原始碼的對映資訊,是錯誤發生時 StackTrace 能指出所在程式位置的依據,另外在進行偵錯時,也需要靠 .pdb 的資訊才能做到檢視變數、設定中斷點、Line by Line 逐行偵錯。
02. NET 編譯時如何決定是否產生 .pdb 檔? .csproj 有個 DebugType 參數,共有五種選項:
full – 以現有平台格式產生 .pdb 檔,在 Windows 為 Windows PDB 檔,在 Linux/macOS 為 Portable PDB
pdbonly – .NET 2.0 之後,pdb-only 基本上等同 full 參考,但 C# 6.0 起有些差異(後面會說明)
portable – 產生 Portable PDB 格式 .pdb。Windows PDB 歷史悠久,過度複雜且殘留 C/C++ 專屬規格,Portable PDB 是重構過的跨平台版本
embedded – 產生 Portable PDB 並合併到 .dll/.exe,不另存 .pdb 檔
none – 不產生 .pdb (並要配合 false)
https://blog.csdn.net/sinat_40003796/article/details/127900870
C# Release中删除pdb文件
因为很多人把PDB理解成:调试文件、Program Debug Database、会泄露代码机密,所以想将其删除。
那只要在VS设置如下: 项目–>生成–>高级–>调试信息–>Non