Now that Visual Studio 2010 and Team Foundation Server 2010 are available, we are seeing customers starting to migrate from Visual Studio 2008 to Visual Studio 2010.
But not every customer is planning on migrating all of these sources to Visual Studio 2010 and Team Foundation Server 2010 at once. For different reasons customers might not even be able to upgrade too Team Foundation Server 2010 yet.
So what is needed is a way to gradually upgrade the source base towards Visual Studio 2010.
This poses challenges for automated builds, since you would need to be able to build Visual Studio 2008 and Visual Studio 2010 solutions side by side.
With Team Foundation Server 2010 Microsoft introduced a new version of their build engine which is based on workflow. There are several workflow templates available to support automated build processes. One of those template is an upgrade template that you can use to execute your “old” builds that were created with Team Build 2008.
So when you upgrade you Team Foundation Server, those builds can still be executed.
However, for some customers, it is not an option to migrate to Team Foundation Server 2010. Although they might start using Visual Studio 2010, they will still be using Team Foundation Server 2008.
From Visual Studio 2010 you can still connect to a 2008 version of Team Foundation Server, and everything will still work. (Of course you won’t be able to use new functionality that is only available with Team Foundation Server 2010.)
So you can use Visual Studio 2010 with Team Foundation Server 2008. But what about Team Build. Can Team Build 2008 build Visual Studio 2010 solutions?
Well it turns out, default it can’t. A Visual Studio 2010 solution uses MSBuild 4.0 which has some new features that are not available in MSBuild 3.5. Furthermore it uses .NET 4.0.
When executing Team Build 2008, default MSBuild 3.5 is used.
When you try to use MSBuild 3.5 to build a Visual Studio 2010 solution, you typically could see errors in the build log like this:
Could not load file or assembly ‘file:///<Some file>‘ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. Confirm that the <UsingTask> declaration is correct, and that the assembly and all its dependencies are available.
error MSB4066: The attribute “Returns” in element <Target> is unrecognized.
So the basic idea to solve this, is try to execute Team Build 2008 using MSBuild 4.0.
It turns out, this is quite easy to accomplish.
Team Build 2008 uses a build service that default is installed to the: %Program Files%Microsoft Visual Studio 9.0Common7IDEPrivateAssemblies folder. In this folder you can find the service configuration file: TFSBuildService.exe.config. This file is just a .NET application configuration file and contains several keys that can be set to tweak the Team Build 2008 build service.
One of those keys is the MSBuildPath key. This key (if set) is used by the service to locate MSBuild.exe and use that version of MSBuild to execute the build process.
So by setting the MSBuildPath key to the .NET 4.0 folder (default: %WINDOWS%Microsoft.NET Frameworkv4.0.30319), we can configure the build service to use MSBuild 4.0.
After updating the configuration file just restart the Visual Studio Team Foundation Build service and your good to go!
Is it really that easy? This is brilliant!
Scary stuff dude. I didn’t quite expect this to be the solution to the problems of last week. One question remains: Does this work for the nightly build of the Silverlight sample app I send you last week?
SIlverlight 4.0 application run fine in this scenario. The nice thing about this solution is, that it runs all project types that are supported in Visual Studio 2010.
Hello. I was wondering if anyone has figured out how to get ClickOnce apps working after this change is made? All my other solutions are working fine so far (VS 2008/ VS 2010), But my click once apps are failing. The runtime version is getting updated to the 4.x framework version rather than with what it was built with.
Anyone know of any pre-processing we can do on the manifest or override one of the targets during teh build itself. We found you cannot do it afterwards since it creates a violation.
THanks for the information for sure on how to get going so easily, but this is our last sticking point. Hopefully we’ll migrate, but until then we need to figure this out.
I got closer but now I am getting the following, any thoughts? I installed 4.0, modified the .config file. Anything else to check or install?
error MSB4019: The imported project “C:Program FilesMSBuildMicrosoftVisualStudiov10.0WebApplicationsMicrosoft.WebApplication.targets” was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
thanks a lot, very helpful
This is NOT a solution. What the author fails to mention is that this “solution” requires that you install VS 2010 IDE onto the TFS 2008 build server. If you’re okay doing that, then it’s as easy as stated. Otherwise, you will encounter many problems, including the one mentioned by David Williams.
Depending on what you need, you might want to install (features) of Visual Studio 2010 on the build server.
In most cases, the .NET framework, SDK en and Team Build service are enough in my situation. For some project types however you would need to install additional features.
Regarding comments about having to install VS2010 on the build server, can you clarify if VS2010 needs to be installed on the TFS app server and the Build server? Maybe a list of what needs to be installed and where would be great. We are using two separate servers and VS2008 projects are currently working great. We are getting errors for our clients that are using VS2010. I am hoping that this is as easy as it sounds. Thank you.
The build is executed on the build server (controller/agent) so the software needs to be installed on the build server.