Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,35 @@ The following options control code generation by the compiler. The new MSBuild s

## DebugType

The **DebugType** option causes the compiler to generate debugging information and place it in the output file or files. Debugging information is added by default.
The **DebugType** option causes the compiler to generate debugging information and place it in the output file or files. The default value is `portable` for both Debug and Release build configurations, which means PDB files are generated by default for all configurations.

```xml
<DebugType>pdbonly</DebugType>
```

For all compiler versions starting with C# 6.0, there is no difference between *pdbonly* and *full*. Choose *pdbonly*. To change the location of the *.pdb* file, see [**PdbFile**](./advanced.md#pdbfile).

### Disabling PDB generation for Release builds

To suppress PDB file generation for Release builds while keeping them for Debug builds, add the following to your project file:

```xml
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<DebugType>none</DebugType>
</PropertyGroup>
```

Alternatively, you can set `DebugSymbols` to `false` for Release builds:

```xml
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
```

> [!NOTE]
> In .NET 8 and later versions, setting `DebugSymbols` to `false` should suppress PDB generation according to the [breaking change documentation](../../../core/compatibility/sdk/8.0/debugsymbols.md). However, for the most reliable way to disable PDB generation, explicitly set `DebugType` to `none`.

The following values are valid:

| Value | Meaning |
Expand All @@ -40,6 +61,7 @@ The following values are valid:
| `pdbonly` | Same as `full`. See the note below for more information. |
| `portable` | Emit debugging information to .pdb file using cross-platform [Portable PDB](https://github.com/dotnet/designs/blob/main/accepted/2020/diagnostics/portable-pdb.md) format. |
| `embedded` | Emit debugging information into the _.dll/.exe_ itself (_.pdb_ file is not produced) using [Portable PDB](https://github.com/dotnet/designs/blob/main/accepted/2020/diagnostics/portable-pdb.md) format. |
| `none` | Don't produce a PDB file. |

> [!IMPORTANT]
> The following information applies only to compilers older than C# 6.0.
Expand Down
Loading