Building in release mode with no pdbs with msbuild
I’ve been having trouble trying to work out how to build our projects in msbuild in release mode without creating the customary pdb files that seem to be created by default.
I tried calling msbuild.exe with the 'Release' configuration:
'C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.Exe ( Proj.csproj /p:OutputPath=\output\path\ /p:Configuration=Release)'
To no avail. It still created the pdb file. Next I tried setting the 'DebugSymbols' property to false:
'C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.Exe ( Proj.csproj /p:OutputPath=\output\path\ /p:Configuration=Release /p:DebugSymbols=false)'
Still it created the file. Finally I found this post which suggested that you actually needed to make the change in the Proj.csproj file itself.
I changed this part of the file so that DebugType is now 'none'. It had a value of 'pdbonly' when I opened the file.
none
true
bin\Release\
TRACE
prompt
4
The pdb is no longer created.
Update This can also be done by passing /p:DebugType=none as a command line argument as Tim points out in the comments.
About the author
I'm currently working on short form content at ClickHouse. I publish short 5 minute videos showing how to solve data problems on YouTube @LearnDataWithMark. I previously worked on graph analytics at Neo4j, where I also co-authored the O'Reilly Graph Algorithms Book with Amy Hodler.