'dotnet publish CLI exclude .pdb
I do (.NET 7):
dotnet publish --self-contained --configuration Release --runtime win7-x64 --output myapp
How do I prevent '.pdb' files in the result ? Ideally just using the CLI ?
Are there any additional steps I can take to decrease the result size ?
Solution 1:[1]
According to this GitHub issue, there are two ways you can disable symbols.
You can either edit the .csproj file to add these two entries:
<DebugType>None</DebugType>
<DebugSymbols>False</DebugSymbols>
Or you can pass the following as part of the dotnet publish command:
/p:DebugType=None /p:DebugSymbols=false
For example:
dotnet publish /p:DebugType=None /p:DebugSymbols=false --self-contained --configuration Release --runtime win7-x64 --output myapp
Solution 2:[2]
To disable .pdb files only for release, add this to your Project.csproj:
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
</PropertyGroup>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | DiplomacyNotWar |
| Solution 2 | lonix |
