When I was migrating our TFS build to .NET Framework 4.0 from 3.5 SP1, I got the following error.
error MSB4062: The “xxx” task could not be loaded from the assembly xxx.dll. Could not load file or assembly ‘file:///xxx.dll’ 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 declaration is correct, and that the assembly and all its dependencies are available.
To resolve this error, you’d have to change the full path to the directory of MSBuild.exe in the TFS build service configuration file.
- Stop the Visual Studio Team Foundation Build service.
- Open the file C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\tfsbuildservice.exe.config.
- Set the path for the new .NET Framework in the MSBuildPath setting:
<add key="MSBuildPath" value="C:\Windows\Microsoft.NET\Framework\v4.0.30319" />
- Start the service.