MSBuild does not build the PDB files
Asked Answered
T

3

14

I have a solution converted from VS2010 to VS2012. In the Release build, I want it to produce PDB files and full debug symbols because I need to run remote debugging in a production environment.

So I set Debug Info to full for Release configuration. I also confirmed the followings are in the project manifest file:

<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimized>true</Optimized>

But when I run MSBuild, the package it creates doesn't include the PDB files. However, if I use Visual Studio's Publish feature with Release configuration, I end up with PDB files on the target web server. What could be wrong with the Build command?

C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe "C:\MyWebApp.csproj"  
  /t:rebuild;package 
  /p:OutPath="C:\MyWebApp\obj" 
  /p:OutputPath="C:\MyWebApp\bin" 
  /p:Configuration=Release 
  /p:Platform=AnyCPU

I tried turning off the Optimized bit, but that didn't help.

Travis answered 27/6, 2014 at 21:22 Comment(0)
B
18

Try adding

/p:DebugSymbols=true

/p:DebugType=full

If you are publishing a web application then you should also add:

/p:ExcludeGeneratedDebugSymbol=false

Bimbo answered 20/4, 2016 at 4:51 Comment(1)
Worked for me just by adding /p:DebugSymbols=truePeptic
N
3

You can access this straight from the command line:

msbuild.exe "C:\\MyWebApp.csproj" /t:rebuild;package /p:OutPath="C:\\MyWebApp\\obj" /p:OutputPath="C:\\MyWebApp\\bin" /p:Configuration=Release /p:Platform=AnyCPU /p:DebugType=pdbonly

Nicolasanicolau answered 27/6, 2014 at 21:30 Comment(5)
I tried that but still didn't produce the PDB files. and I don't even have ExcludeGeneratedDebugSymbol in the project manifest mentioned here. #15562811Travis
Have you tried it without the extra properties... (OutPath, OutputPath, ...)?Nicolasanicolau
I'm pretty sure that, when quoting property values, you have to escape backslashes. C:\Foo.csproj when quoted becomes "C:\\Foo.csproj"Nicolasanicolau
I tried without the extra properties but no PDB still.Travis
The backslashes are working for me, my actualy output path is a network share and I get the final zip file there.Travis
B
0

In your '.csproj' file, under 'Target' and 'csc' be sure to set 'EmitDebugInformation' to true, something like this:

  <Target Name="Build">
    <MakeDir Directories="$(OutputPath)" Condition="!Exists('$(OutputPath)')" />
    <Csc
      Sources="@(Compile)"
      OutputAssembly="$(OutputPath)$(AssemblyName).exe"
      EmitDebugInformation="true" 
      />
  </Target>
Broeder answered 10/6, 2024 at 13:36 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.