views:

148

answers:

1

Hello,

I am trying to generate a release build with no pdb files generated. I have seen numerous posts that suggest right-clicking on the project, selecting Properties, going to the Build tab and then to the Advanced... butoon and changing Debug Info to none. This works and all, but I need to do this for a build of ~50 solutions which contain ~25 projects each! Other posts mention editing the appropriate .csproj file, but again, with so many projects, this would take a long time. Is there any way to achieve this via the TFSBuild.proj file?

I have tried adding the following to the TFSBuild.proj file, with no luck.

<PropertyGroup>
  <Configuration>Release</Configuration>
  <Platform>AnyCPU</Platform>
</PropertyGroup>

<PropertyGroup>
  <DebugSymbols>false</DebugSymbols>
  <DebugType>none</DebugType>
  <Optimize>true</Optimize>
</PropertyGroup>

The following line prints out Release|AnyCPU, none, and false, but I still see .pdb file in the $(OutputDir) folder.

<Message Text="$Configuration|Platform): $(Configuration)|$(Platform)" />
<Message Text="DebugType is: $(DebugType)"/>
<Message Text="DebugSymbols is: $(DebugSymbols)"/>

Thanks in advance, Urvi

A: 

I am not entirely sure (don't have team build installed), but it is very likely that when you change such properties in the TFSBuild poject, they do not propagate to your actual project files since the actual solutions/projects are built by launching another MSBuild task, and the responsible target in Microsoft.TeamFoundation.Build.targets does not pass those Properties to the task.

For example, this is the target "CallCompile" in aforementioned file (again, I'm not sure if this is what your build scenario uses but the idea is the same):

<Target Name="CallCompile" DependsOnTargets="$(CoreCompileDependsOn)">
  <!-- Pass in all properties that users might want during the course of the compile targets. -->
  <MSBuild Projects="$(MSBuildProjectFile)"
           Properties="a lot of properties, but not DebugSymbols etc"
           Targets="CoreCompile">
  </MSBuild>
</Target>

So you might get away with adding the properties you want to the targets file, but:

  • that means you have to change that file each time you upgrade
  • it might not be the desired behaviour for all your projects
  • last but not least: if the project files invoked also contain DebugSymbols/..., the property values in your file simply override the ones passed by the MSBuild task, so in the end you still have to change all project files to deal with that

One way to achive what you want, is to write a script in your language of choice that lists all *.csproj files under a certain directory, then modifies each file to replace true with false. Or even faster: do a search on *.csproj in explorer, open all files at once in an editor and perform a Find/Replace on all open files.

stijn