Tuesday, October 14, 2008

Custom Build Properties in Central Team Build

I’m wrapping up the configuration of my Team Build in Team Foundation Server for a project, and ran into a problem with an MSBuild command.  My application writes to the SharePoint Unified Logging System (ULS) logs, and the class required to do that uses “unsafe” code.  Unsafe code causes the regular compiler (csc.exe) to throw an error while building in Visual Studio.  Overcoming that can be done in the IDE – simply open the “Properties” window for your project and check off “Allow unsafe code blocks” on the “Build” tab for all different configurations you plan to use (for example, “Debug” and “Release”). 

It’s less straight-forward when your build is happening on another box, namely the Team Server.  To do this (assuming you’ve taken the steps from Rob’s posts to set up central build to begin with), you simply need to add this property in your TFSBuild.proj file: 

  <CustomPropertiesForBuild>AllowUnsafeBlocks=true</CustomPropertiesForBuild>


As we become more standardized on using the ULS logs as our primary mechanism for diagnostics in SharePoint web parts and other artifacts, you might run into this.  If you do, hope this helps!

No comments: