Ray Cheng
Ray Cheng

Reputation: 12586

MSBuild does not build the PDB files

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.

Upvotes: 14

Views: 5619

Answers (3)

nwsmith
nwsmith

Reputation: 526

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>

Upvotes: 0

CRice
CRice

Reputation: 12567

Try adding

/p:DebugSymbols=true

/p:DebugType=full

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

/p:ExcludeGeneratedDebugSymbol=false

Upvotes: 18

Jay Harris
Jay Harris

Reputation: 10065

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

Upvotes: 3

Related Questions