From edbfc6bf91b3d1d05e8b4b8e7d75509a40c5c95e Mon Sep 17 00:00:00 2001 From: Matt Kotsenas Date: Wed, 28 Aug 2024 10:04:28 -0700 Subject: [PATCH 1/5] Refactor "PDB distributions" section of README --- README.md | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index ab581e879..9df84f885 100644 --- a/README.md +++ b/README.md @@ -208,16 +208,6 @@ The VC++ linker supports `/SOURCELINK` [switch](https://docs.microsoft.com/en-us If you distribute the library via a package published to [NuGet.org](http://nuget.org), it is recommended to build a [symbol package](https://docs.microsoft.com/en-us/nuget/create-packages/symbol-packages-snupkg) and publish it to [NuGet.org](http://nuget.org) as well. This will make the symbols available on [NuGet.org symbol server](https://docs.microsoft.com/en-us/nuget/create-packages/symbol-packages-snupkg#nugetorg-symbol-server), where the debugger can download it from when needed. -Alternatively, Portable PDBs can be included in the main NuGet package by setting the following property in your project: - -```xml - - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - -``` - -Keep in mind that including PDBs in the .nupkg increases the size of the package and thus restore time for projects that consume your package, regardless of whether the user needs to debug through the source code of your library or not. - .snupkg symbol packages have following limitations: - They do not support Windows PDBs (generated by VC++, or for managed projects that set build property `DebugType` to `full`) @@ -225,8 +215,29 @@ Keep in mind that including PDBs in the .nupkg increases the size of the package - The consumer of the package also needs Visual Studio 2017 Update 9 debugger. - Not supported by [Azure DevOps Artifacts](https://azure.microsoft.com/en-us/services/devops/artifacts) service. -Consider including PDBs in the main package if it is not possible to use .snupkg for the above reasons. -For managed projects, consider switching to Portable PDBs by setting `DebugType` property to `portable`. This is the default for .NET SDK projects, but not classic .NET projects. +If a .snupkg does not work for your scenario, consider including debug information in the main package. + +> [!IMPORTANT] +> Keep in mind that including debug information in the .nupkg increases the size of the package and thus restore time for projects that consume your package, regardless of whether the user needs to debug the source code of your library or not. + +The simplest way to include debug information is to embed Portable PDBs directly in the assembly by setting the following property in your project: + +```xml + + embedded + +``` + +Alternatively, you can include PDB files in the main NuGet package by setting the following property in your project: + +```xml + + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + +``` + +> [!TIP] +> Classic .NET projects should also consider changing the `DebugType` property to `portable` (or `embedded`) to match .NET SDK projects. ## Builds From 6361f47513b1667cd409929376f02e0ff6963bef Mon Sep 17 00:00:00 2001 From: Matt Kotsenas Date: Mon, 13 Jan 2025 11:47:23 -0800 Subject: [PATCH 2/5] Add pros / cons table for symbol package types --- README.md | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9df84f885..b0aa24c61 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,18 @@ The VC++ linker supports `/SOURCELINK` [switch](https://docs.microsoft.com/en-us ## PDB distributions +There are three main ways to distribute PDBs: via a dedicated .snupkg, including them in the main package, and embedding them directly into the assembly. Each has advantages and drawbacks, depending on your use case. + +| | snupkg | Include in main package | Embed in assembly | +|-----------------------------------------|-----------------------------|-------------------------|-------------------| +| No user opt-in required to load symbols | ✅ | ❌ | ✅ | +| No increase in size of main package | ✅ | ❌ | ❌ | +| No increase in size of assemblies | ✅ | ✅ | ❌ | +| Supported by all package feeds | ❌ (Supported on NuGet.org) | ✅ | ✅ | +| Supports all symbol types | ❌ (Portable symbols only) | ✅ | ✅ | + +### .snupkg symbol packages + If you distribute the library via a package published to [NuGet.org](http://nuget.org), it is recommended to build a [symbol package](https://docs.microsoft.com/en-us/nuget/create-packages/symbol-packages-snupkg) and publish it to [NuGet.org](http://nuget.org) as well. This will make the symbols available on [NuGet.org symbol server](https://docs.microsoft.com/en-us/nuget/create-packages/symbol-packages-snupkg#nugetorg-symbol-server), where the debugger can download it from when needed. .snupkg symbol packages have following limitations: @@ -215,29 +227,39 @@ If you distribute the library via a package published to [NuGet.org](http://nuge - The consumer of the package also needs Visual Studio 2017 Update 9 debugger. - Not supported by [Azure DevOps Artifacts](https://azure.microsoft.com/en-us/services/devops/artifacts) service. -If a .snupkg does not work for your scenario, consider including debug information in the main package. +If a .snupkg does not work for your scenario, consider including debug information in the main package via one of the alternatives. -> [!IMPORTANT] -> Keep in mind that including debug information in the .nupkg increases the size of the package and thus restore time for projects that consume your package, regardless of whether the user needs to debug the source code of your library or not. +### Include in main package -The simplest way to include debug information is to embed Portable PDBs directly in the assembly by setting the following property in your project: +You can include PDB files in the main NuGet package by setting the following property in your project: ```xml - embedded + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb ``` -Alternatively, you can include PDB files in the main NuGet package by setting the following property in your project: +> [!IMPORTANT] +> Keep in mind that including debug information in the .nupkg increases the size of the package and thus restore time for projects that consume your package, regardless of whether the user needs to debug the source code of your library or not. + +> [!IMPORTANT] +> When including PDB files in the main package, projects that consume the package must _also_ opt-in to copying the symbols into their own output directory. Starting in .NET 7 this can be controlled via the [`CopyDebugSymbolFilesFromPackages`](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#copydebugsymbolfilesfrompackages) property. + +> [!TIP] +> Classic .NET projects should also consider changing the `DebugType` property to `portable` (or `embedded`) to match .NET SDK projects. + +### Embed in assembly + +You can embed Portable PDB debug information directly in the assembly by setting the following property in your project: ```xml - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + embedded ``` -> [!TIP] -> Classic .NET projects should also consider changing the `DebugType` property to `portable` (or `embedded`) to match .NET SDK projects. +> [!IMPORTANT] +> Keep in mind that embedding debug including debug information in assembly both increases the size of the package and thus restore time for projects that consume your package, regardless of whether the user needs to debug the source code of your library or not, and also may impact assembly load performance for very large assemblies. ## Builds From e7d41832431559575b5de967db3aeefc75b74289 Mon Sep 17 00:00:00 2001 From: Matt Kotsenas Date: Mon, 13 Jan 2025 13:33:16 -0800 Subject: [PATCH 3/5] Fix edits lost in merge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9f4d11acc..b3bb78dc5 100644 --- a/README.md +++ b/README.md @@ -244,7 +244,7 @@ If you distribute the library via a package published to [NuGet.org](http://nuge - They do not support Windows PDBs (generated by VC++, or for managed projects that set build property `DebugType` to `full`) - They require the library to be built by newer C#/VB compiler (Visual Studio 2017 Update 9). -- The consumer of the package also needs Visual Studio 2017 Update 9 debugger. +- The consumer of the package also needs Visual Studio 2017 Update 9 or newer. - Not supported by [Azure DevOps Artifacts](https://azure.microsoft.com/en-us/services/devops/artifacts) service. If a .snupkg does not work for your scenario, consider including debug information in the main package via one of the alternatives. From 9a7d1b61df7e2bda77e960f7beca1768ae650796 Mon Sep 17 00:00:00 2001 From: Matt Kotsenas Date: Mon, 10 Feb 2025 17:38:24 -0800 Subject: [PATCH 4/5] Remove "all types" from chart for PDB distributions Since Windows-only PDBs are legacy for managed code, and this section is about managed code, the "supports all types" row isn't really relvant. Remove it. --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index b3bb78dc5..868e77634 100644 --- a/README.md +++ b/README.md @@ -226,7 +226,7 @@ The VC++ linker supports `/SOURCELINK` [switch](https://docs.microsoft.com/en-us ## PDB distributions -There are three main ways to distribute PDBs: via a dedicated .snupkg, including them in the main package, and embedding them directly into the assembly. Each has advantages and drawbacks, depending on your use case. +There are three main ways to distribute PDBs for managed code: via a dedicated .snupkg, including them in the main package, and embedding them directly into the assembly. Each has advantages and drawbacks, depending on your use case. | | snupkg | Include in main package | Embed in assembly | |-----------------------------------------|-----------------------------|-------------------------|-------------------| @@ -234,7 +234,6 @@ There are three main ways to distribute PDBs: via a dedicated .snupkg, including | No increase in size of main package | ✅ | ❌ | ❌ | | No increase in size of assemblies | ✅ | ✅ | ❌ | | Supported by all package feeds | ❌ (Supported on NuGet.org) | ✅ | ✅ | -| Supports all symbol types | ❌ (Portable symbols only) | ✅ | ✅ | ### .snupkg symbol packages From 96c30157df479cba7e1bb067f644387fb2738f33 Mon Sep 17 00:00:00 2001 From: Matt Kotsenas Date: Mon, 10 Feb 2025 17:43:58 -0800 Subject: [PATCH 5/5] Copy edits for note about embedding size --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 868e77634..cfee7909b 100644 --- a/README.md +++ b/README.md @@ -278,7 +278,7 @@ You can embed Portable PDB debug information directly in the assembly by setting ``` > [!IMPORTANT] -> Keep in mind that embedding debug including debug information in assembly both increases the size of the package and thus restore time for projects that consume your package, regardless of whether the user needs to debug the source code of your library or not, and also may impact assembly load performance for very large assemblies. +> Keep in mind that embedding debug information in the assembly increases binary size. Larger binaries increase application size, NuGet restore time, assembly load time (if assemblies are very large), regardless of whether the user needs to debug the source code of your library or not. ## Builds