源链接Source Link

源链接是一种使开发人员可以从 NuGet 对 .NET 程序集进行源代码调试的技术。Source Link is a technology that enables source code debugging of .NET assemblies from NuGet by developers. 源链接在创建 NuGet 包时执行,然后将源代码管理元数据嵌入在程序集和包中。Source Link executes when creating the NuGet package and embeds source control metadata inside assemblies and the package. 下载包并且在 Visual Studio 中启用了源链接的开发人员可以单步执行其源代码。Developers who download the package and have Source Link enabled in Visual Studio can step into its source code. 源链接提供源代码管理元数据来创造出色的调试体验。Source Link provides source control metadata to create a great debugging experience.

可以在 dotnet/sourceLink GitHub 存储库上找到有关使用源链接的说明。Instructions for using Source Link can be found on the dotnet/sourcelink GitHub repository.

可以使用 NuGet 包资源管理器以确认源链接元数据是否已成功嵌入在包中。You can use NuGet Package Explorer to confirm that the Source Link metadata has been successfully embedded in the package. 检查 Repository 元数据是否存在并具有注释标识符,以及 .pdb 文件是否与每个目标的 .dll 放置在一起。Check the Repository metadata is present with a commit identifier and that .pdb files are located with each target's .dll.

NuGet 包资源管理器中的源链接Source Link in NuGet Package Explorer

✔️ 请考虑使用源链接将源代码管理元数据添加到程序集和 NuGet 包。✔️ CONSIDER using Source Link to add source control metadata to your assemblies and NuGet packages.

提示

可以通过将调试器特性添加到类型来进一步增强开发人员的调试体验。You can further enhance a developer's debugging experience by adding debugger attributes to your types.

✔️ 请考虑发布符号文件 (*.pdb)。✔️ CONSIDER publishing symbol files (*.pdb).

为获得最佳调试体验,库应发布符号文件并使用源链接。For the best debugging experience your library should publish symbol files as well as use Source Link. 有关符号文件和符号包的详细信息,请参阅符号包For more information about symbol files and symbol packages, see Symbol packages.

✔️ 考虑启用确定性版本。✔️ CONSIDER enabling deterministic builds.

确定性版本可用于验证生成的二进制文件是否是从指定的源生成的,并提供可跟踪性。Deterministic builds enable verification that the resulting binary was built from the specified source and provide traceability. 有关确定性版本的详细信息和启用它们的说明,请参阅确定性版本For more information about deterministic builds and instructions for enabling them, see Deterministic Builds.