Delen via


Building VS2008 projects with TFS Build 2010

TFS Build 2010 uses MSBuild 4.0 to compile the solutions/projects and MSBuild 4.0 is capable of handling the backward compatibility with .NET 3.5 projects. So you will be able to build VS2008 projects in TFS Build without having to upgrade them to 2010 provided required tools are installed on the build machine.

MSBuild 4.0 comes in 32bit and 64bit versions and TFS Build provides a way to be able to choose one over the other. In the build process, TFS Build exposes a property called “MSBuild Platform” that can have 3 values – “Auto”, “x86” and “x64”. The default is “Auto” which uses the 64bit version of MSBuild on 64 bit machines and 32 bit version on 32 bit build machines.

MSBuildPlatform

There are some additional requirements/workarounds needed for some project types to work with MSBuild 4.0.

VC++ 2008 projects:

If you are building VC++ 2008 projects, you will need to install VS2008 or the Windows SDK (v6.1) to lay down vcbuild.exe and its dependencies. If your build machine is 64 bit, you will also need to include the path to vcbuild.exe in the PATH environment variable and restart the TFSBuildServiceHost service.

If the build machine is 64 bit but you are specifically targeting “MSBuild Platform = x86”, you might see errors similar to:

“C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets (1682): Use of Tracker.exe is required to correctly incrementally generate resources in some circumstances, such as when building on a 64-bit OS using 32-bit MSBuild. A build that falls into this category was attempted, but Tracker.exe could not be found. Please verify that it exists in the appropriate .NET Framework directory or turn off incremental building of GenerateResource via setting the "TrackFileAccess" property to "false".”

To workaround this install VS2010 (to install the Windows SDK (v7.0A)) to lay down Tracker.exe and its dependencies.

.NET Compact Framework projects:

Update msbuild.exe.config file on the build machine as suggested in Jim Lamb’s post

Test projects:

If your build machine is 64 bit, you might see errors similar to “ResGen: Could not load referenced assembly "C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.UnitTestFramework\v4.0_10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll". Caught a BadImageFormatException saying "Could not load file or assembly 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.UnitTestFramework\v4.0_10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.".”

This is an issue with MSBuild 4.0 x64 when targeting 3.5 projects. To workaround this you can try one of the following:

  • Use the 32 bit version of msbuild by setting “MSBuild Platform”=x86
  • Modify the project to include the full fusion name for the 9.0 version of the Microsoft.VisualStudio.QualityTools.UnitTestFramework
  • Register the same assemblyfolderEx locations under the 64 bit hive as were registered under the 32 bit hive. This key tells MSBuild to look in the IDE\PublicAssemblies folder where the unit test assembly is- HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx\Public Assemblies 9. Create the same key in the non WOW registry hive as well - HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx\Public Assemblies 9

[Update]

If you are using private accessors in your unit tests, you will see errors when running tests. Adam Root wrote a blog describing the problem and a workaround. We are trying to get this issue fixed for RTM.

Publishing VS2008 test results will fail with a 404 error if you don’t have VS2008 SP1 and the Forward Compat GDR for TFS 2010 installed.

Can I specify TFS Build to use MSBuild 3.5 instead?

This is not possible out of the box. The loggers used by TFS Build are compiled against .NET framework 4.0 and MSBuild 3.5 will fail to load them.

Comments

  • Anonymous
    November 25, 2009
    Hi Madhuri, There is also an issue with builiding solutions that contain non-MSBuild projects, for example setup projects. See my blog post about this: http://geekswithblogs.net/jakob/archive/2009/11/24/tfs-2010-beta-2-ndash-upgrading-builds-from-tfs-2008.aspx Work around is to remove those projects from the solution configuration.

  • Anonymous
    December 04, 2009
    Thanks for pointing out Jakob. There are a few more issues around building test projects and running tests. I should do a follow up post once those are nailed down.

  • Anonymous
    August 18, 2010
    Wht is "full fusion name for the 9.0 version"

  • Anonymous
    August 18, 2010
    I am using projects developed in VS2008 and TFS2010.when i start the build i am getting the below error Also when the same is done in TFS2008 i dont face any  issue. RsGen: Could not load referenced assembly "C:Builds2CapitalxCX6SourcesDatabaseCapitalX_CLRbinDebugCapitalX_CLR.dll".  Caught a FileNotFoundException saying "Could not load file or assembly 'C:Builds2CapitalxCX6SourcesDatabaseCapitalX_CLRbinDebugCapitalX_CLR.dll' or one of its dependencies. The system cannot find the file specified.".

  • Anonymous
    September 19, 2011
    HI Madhuri,   I am trying to build VS2008 solutions in TFS2008, but I am encountering a lot of issues, and have not been able to get one successful build yet. I tried one customization with the Output directory, and that is what I changed in the Build template. But I keep getting errors, which on being resolved goes to the next solution. I am very frustrated . I have installed VS2010, Team Foundation Build Service and VS2008 with SP1 and forward compatibility on this machine. Should I compile those VS2008 solutions from VS2008, against TFS2010, or should I use VS2010 to compile against TFS2010? Please help me.

  • Anonymous
    September 28, 2011
    Ananya, if you are building VS2008 projects with TFS 2008, you shouldn't need to install VS2010. Please post your issues on the support forum - social.msdn.microsoft.com/.../threads

  • Anonymous
    August 31, 2012
    Madhuri, I am very thankful to you for your article, Its an awesome piece of information that you have shared.

  • Anonymous
    September 19, 2012
    Well I have been trying and figuring out to get successful builds through TFS2010 build server for VS2008 projects as most of our projects are on VS2008.  Earlier I managed to connect to TFS2010 using VS2008 buy  installing the following on my pc : • VS 2008 Team Explorer • VS 2008 Service Pack 1 • Visual Studio Team System 2008 Service Pack 1 Forward Compatibility Update for Team Foundation Server 2010 After installing all the above I was able to connect the TFS build when I created a build definition in order to test a automated build for VS2008 projects but got no success. I was getting a build succeed  message as can be seen in the below snap: during the build TFS  is not putting projects dlls in binaries folder  of the working directory on the build machine: Only a log file is being placed in the drop folder I specified for published code