Udostępnij za pośrednictwem


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

  1. check-out TFSBuild.rsp file corresponding to your BuildType (you will find this file at the same location as TFSBuild.proj)
  2. add /v:diagnostic to rsp file
  3. 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

<!--

    <system.diagnostics>

        <switches>

            <add name="API" value="4" />

            <add name="Authentication" value="4" />

            <add name="Database" value="4" />

            <add name="General" value="4" />

        </switches>

 

        <trace autoflush="true" indentsize="4">

            <listeners>

                <add name="myListener"

                    type="System.Diagnostics.TextWriterTraceListener"

                    initializeData="c:\logs\buildmachine.log" />

            </listeners>

        </trace>

    </system.diagnostics>

- ->

  • 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

 

Build arguments:

  1. /nologo 
  2. /p:PortfolioProject="MyDummyProj"
  3. /p:TeamProject="MyDummyProj"
  4. /p:BuildType="MyBuildType"
  5. /p:DropLocation=\\<MachineName>\droplocation
  6. /p:BuildDirectoryPath="c:\buildlocation"
  7. /p:TeamFoundationServerUrl=https://<ServerName>:8080
  8. /p:IsDesktopBuild="false"
  9. /p:FxCopDir="C:\Program Files\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\"
  10. /p:TeamBuildRefPath="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies"
  11. /p:LastBuildNumber="MyBuildType_20050803.3"
  12. /p:LastGoodBuildNumber="MyBuildType_20050803.3"
  13. /p:BuildNumber="MyBuildType_20050803.4"
  14. /p:ToolSpecificId="08032005_084015_57743"
  15. /p:BuildURI=vstfs:///Build/Build/08032005_084015_57743
  16.  /p:ConfigurationFileURI="vstfs:///VersionControl/VersionedItem/MyDummyProj%252fTeamBuildTypes%252fMyBuildType%252fTFSBuild.proj%2526changesetVersion%253d16%2526deletionId%253d0"
  17. /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
  18. /t:EndToEndIteration
  19. TFSBuild.proj
  20. @TFSBuild.rsp

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).

Comments