Skip to content

Commit 0dd14e7

Browse files
authored
Refactor "PDB distributions" section of README (#1271)
* Refactor "PDB distributions" section of README * Add pros / cons table for symbol package types * Fix edits lost in merge * 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. * Copy edits for note about embedding size
1 parent c7cdd65 commit 0dd14e7

File tree

1 file changed

+41
-9
lines changed

1 file changed

+41
-9
lines changed

README.md

+41-9
Original file line numberDiff line numberDiff line change
@@ -226,27 +226,59 @@ The VC++ linker supports `/SOURCELINK` [switch](https://docs.microsoft.com/en-us
226226

227227
## PDB distributions
228228

229+
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.
230+
231+
| | snupkg | Include in main package | Embed in assembly |
232+
|-----------------------------------------|-----------------------------|-------------------------|-------------------|
233+
| No user opt-in required to load symbols ||||
234+
| No increase in size of main package ||||
235+
| No increase in size of assemblies ||||
236+
| Supported by all package feeds | ❌ (Supported on NuGet.org) |||
237+
238+
### .snupkg symbol packages
239+
229240
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.
230241

231-
Alternatively, Portable PDBs can be included in the main NuGet package by setting the following property in your project:
242+
.snupkg symbol packages have following limitations:
243+
244+
- They do not support Windows PDBs (generated by VC++, or for managed projects that set build property `DebugType` to `full`)
245+
- They require the library to be built by newer C#/VB compiler (Visual Studio 2017 Update 9).
246+
- The consumer of the package also needs Visual Studio 2017 Update 9 or newer.
247+
- Not supported by [Azure DevOps Artifacts](https://azure.microsoft.com/en-us/services/devops/artifacts) service.
248+
249+
If a .snupkg does not work for your scenario, consider including debug information in the main package via one of the alternatives.
250+
251+
### Include in main package
252+
253+
You can include PDB files in the main NuGet package by setting the following property in your project:
232254

233255
```xml
234256
<PropertyGroup>
235257
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
236258
</PropertyGroup>
237259
```
238260

239-
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.
261+
> [!IMPORTANT]
262+
> 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.
240263
241-
.snupkg symbol packages have following limitations:
264+
> [!IMPORTANT]
265+
> 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.
242266
243-
- They do not support Windows PDBs (generated by VC++, or for managed projects that set build property `DebugType` to `full`)
244-
- They require the library to be built by newer C#/VB compiler (Visual Studio 2017 Update 9).
245-
- The consumer of the package also needs Visual Studio 2017 Update 9 or newer.
246-
- Not supported by [Azure DevOps Artifacts](https://azure.microsoft.com/en-us/services/devops/artifacts) service.
267+
> [!TIP]
268+
> Classic .NET projects should also consider changing the `DebugType` property to `portable` (or `embedded`) to match .NET SDK projects.
269+
270+
### Embed in assembly
271+
272+
You can embed Portable PDB debug information directly in the assembly by setting the following property in your project:
273+
274+
```xml
275+
<PropertyGroup>
276+
<DebugType>embedded</DebugType>
277+
</PropertyGroup>
278+
```
247279

248-
Consider including PDBs in the main package if it is not possible to use .snupkg for the above reasons.
249-
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.
280+
> [!IMPORTANT]
281+
> 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.
250282
251283
## Builds
252284

0 commit comments

Comments
 (0)