How to debug build break in Team Build?
Increasing the verbosity of logger
Team build invokes logger with normal verbosity. It is done to avoid showing unnecessary details about build in the log file and make it more readable. Sometime when you introduce custom tasks or there is some regression in the existing code, it becomes hard to figure out the problem.
Normal verbosity does not give much details and you might want to have detailed log of exact sequence of events/tasks/targets that resulted in failure. You can increase the verbosity of the logger by doing the following steps
- check-out TFSBuild.rsp file corresponding to your BuildType (you will find this file at the same location as TFSBuild.proj)
- add /v:diagnostic to rsp file
- check-in the rsp file.
The rsp file will be passed by the Build Service to the msbuild command and all the attached loggers will start logging with full verbosity. Now your build log will have the value of all the msbuild properties, items, exact order in which targets and tasks were invoked, the value of conditions, etc.
Invoking specific target with team build
Ok, now you have identified the target/task that is not working correctly. You want to invoke the given target with exactly the same arguments to get the repro. First you have to get the build arguments You can do that by enabling the build machine service logging. The steps are
- start --> run --> service.msc
- stop “team build service”
- open %Program Files%\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\TfsBuildService.exe.config
- uncomment the following lines to enable logging. You can also specify the location of buildmachine.log file
<add name="API" value="4" />
<add name="Authentication" value="4" />
<add name="Database" value="4" />
<add name="General" value="4" />
<trace autoflush="true" indentsize="4">
- make sure that folder where the log file will be created exists
- make sure that folder pointed by “initializeData” exists
- start “team build service”
After invoking another build, you can open the buildmachine.log file to get the msbuild arguments for that specific invocation. You can find the arguments by searching for tag “Build arguments:”. For example you will have something like
- /p:FxCopDir="C:\Program Files\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\"
- /p:TeamBuildRefPath="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies"
- /logger:BuildLogger,"C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.Build.Server.Logger.dll";"BuildURI=vstfs:///Build/Build/08032005_084015_57743;PortfolioProject=MyDummyProj;TFServer=https://<ServerName>:8080;ServerUICulture=1033;" /logger:FileLogger,Microsoft.Build.Engine;logfile=BuildLog.txt;encoding=Unicode; /noconsolelogger
You can run the msbuild command with the appropriate arguments on the command line. If you are debugging the specific task or target it is recommended to not pass any logger (i.e do not pass 17th argument in the list). If you want to run specific target you can pass the name of target using /t switch (18th argument). You are also responsible for make sure that all the prerequisites of the target are executed properly. For example before invoking "Get" task, you have to make sure that "CreateWorkspace" task has already created proper workspace. Please note that this is different from Desktop build and you should not set the "IsDeskTopBuild" flag to true. Setting desktop flag to true might result in skipping the target.
Do drop a line if you need additional information ...
Disclaimer: The information mentioned is for beta3 bits (releasing in September 2005).