Missing Microsoft.Build.Tasks.v4.0.dll on visual studio online tfs build - tfs

I am trying to build my project with visual studio online.
I am getting the following error.
C:\a\src\.nuget\nuget.targets (71): The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Build.Tasks.v4.0.dll". Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Build.Tasks.v4.0.dll' or one of its dependencies. The system cannot find the file specified.
This is coming from the nuget.targets file in my solution.
<UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<EnvKey ParameterType="System.String" Required="true" />
<EnvValue ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
Environment.SetEnvironmentVariable(EnvKey, EnvValue, System.EnvironmentVariableTarget.Process);
}
catch {
}
]]>
</Code>
</Task>
</UsingTask>
I have updated nuget.exe to latest and have not changed anything in nuget.targets.

The problem was that some of the class libraries in the solution had the default value :
ToolsVersion="12.0"
changing that to
ToolsVersion="4.0"
made it work on TFS online

I ran into this after upgrading a project to .NET 4.5.2. Seems to be a conflict between the .NET 4.5 point releases and the old way to do NuGet package restore (MSBuild-Integrated package restore vs Automatic Package Restore).
I was able to solve the issue by migrating NuGet to the new way of doing package restore: http://docs.nuget.org/consume/package-restore/migrating-to-automatic-package-restore
More info: http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html

Related

G1ANT SDK installation for VS 2019

I cloned the repository at the G1ANT.Robot github page and opened G1ANT.Sdk.sln in VS Studio 2019 CE 16.1.5, Win10 Pro with latest updates. I left the default build properties as "Debug" and "AnyCPU". The following error can't be resolved, as I don't have the required files on my system:
Severity Code Description Project File Line Suppression State
Warning Could not resolve this reference. Could not locate the assembly "Microsoft.VisualStudio.CoreUtility, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. G1ANT.AddonTemplate
There are other errors, all seemingly related to dependencies on an earlier version or versions of VS (some I believe to be v14.0 dependent, some to be v15.0 dependent).
I do have the Microsoft.VisualStudio.CoreUtility available, but the version is 16.0 (i.e. VS 2019). In short, it appears that compilation may require an earlier version of VS than the one I have. Installing such an earlier version is not an option for me.
Thanks,
burque505
Yes, file /G1ANT.Sdk/G1ANT.Sdk/source.extension.vsixmanifest should be changed:
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[15.0,]" />
<InstallationTarget Id="Microsoft.VisualStudio.Pro" Version="[15.0,]" />
<InstallationTarget Id="Microsoft.VisualStudio.Enterprise" Version="[15.0,]" />
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.6.1,)" />
</Dependencies>
You can download the correct installation: https://github.com/G1ANT-Robot/G1ANT.Sdk/raw/master/G1ANT.Sdk.vsix
I believe it will help :)

Unable to find version " " of package " "

I'm trying to deploy my website from github to Azure but there are some errors showing up every time I try to do it, this is part of the log from Azure:
Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling ASP.NET Core Web Application deployment with MSBuild.
MSBuild auto-detection: using msbuild version '14.0' from 'D:\Program Files (x86)\MSBuild\14.0\bin'.
Restoring NuGet package Microsoft.Extensions.Caching.Abstractions.1.0.0.
Restoring NuGet package Microsoft.Extensions.Caching.Memory.1.0.0.
Restoring NuGet package Microsoft.Extensions.DependencyInjection.1.0.0.
WARNING: Unable to find version '1.0.0' of package 'Microsoft.Extensions.Caching.Abstractions'.
D:\home\.nuget: Package 'Microsoft.Extensions.Caching.Abstractions.1.0.0' is not found on source 'D:\home\.nuget'.
https://api.nuget.org/v3/index.json: Could not find file 'D:\home\.nuget\microsoft.extensions.caching.abstractions\1.0.0\microsoft.extensions.caching.abstractions.1.0.0.nupkg'.
It does that for a lot of Nuget packages that I have, maybe all of them.
Then after the Warning messages, this other message is showed:
Restoring packages for D:\home\site\repository\src\LIGMarine\project.json...
Restoring packages for tool 'BundlerMinifier.Core' in D:\home\site\repository\src\LIGMarine\project.json...
Restoring packages for tool 'Microsoft.AspNetCore.Razor.Tools' in D:\home\site\repository\src\LIGMarine\project.json...
Restoring packages for tool 'Microsoft.AspNetCore.Server.IISIntegration.Tools' in D:\home\site\repository\src\LIGMarine\project.json...
Committing restore...
Writing lock file to disk. Path: D:\home\site\repository\src\LIGMarine\project.lock.json
D:\home\site\repository\src\LIGMarine\LIGMarine.xproj
Restore completed in 5151ms.
And then comes the error messages:
Errors in packages.config projects
Unable to find version '1.0.0' of package 'Microsoft.Extensions.Caching.Abstractions'.
D:\home\.nuget: Package 'Microsoft.Extensions.Caching.Abstractions.1.0.0' is not found on source 'D:\home\.nuget'.
https://api.nuget.org/v3/index.json: Could not find file 'D:\home\.nuget\microsoft.extensions.caching.abstractions\1.0.0\microsoft.extensions.caching.abstractions.1.0.0.nupkg'.
Feeds used:
D:\home\.nuget
D:\home\.nuget: Package 'System.Interactive.Async.3.0.0' is not found on source 'D:\home\.nuget'.
https://api.nuget.org/v3/index.json: Could not find file 'D:\home\.nuget\system.interactive.async\3.0.0\system.interactive.async.3.0.0.nupkg'
This is a resume of the Azure log, I have read about this errors and I have created a Nuget.Config file as I show in the picture, this file is inside the Solution Items folder
This is the code that I have inside the Nuget.Config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<disabledPackageSources />
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>
According to this messages, the Nuget packages cannot be found...
Feeds used:
D:\home\.nuget
D:\home\.nuget: Package 'System.Interactive.Async.3.0.0' is not found on source 'D:\home\.nuget'.
https://api.nuget.org/v3/index.json: Could not find file 'D:\home\.nuget\system.interactive.async\3.0.0\system.interactive.async.3.0.0.nupkg'
Maybe it's not looking for the packages the way it should, I'm not sure what means this path: 'D:\home\.nuget\'
What should I do?
EDIT
These are the packages that are not being found, I don't think these are private packages that cannot be found within https://api.nuget.org/v3/index.json:
Microsoft.Extensions.Caching.Abstractions
Microsoft.Extensions.Caching.Memory
Microsoft.Extensions.DependencyInjection
System.Interactive.Async
System.Linq
System.Linq.Expressions
System.Linq.Queryable
System.Globalization
System.Reflection
System.ObjectModel
System.Resources.ResourceManager
System.Reflection.Extensions
System.Runtime
System.Runtime.Extensions
System.Runtime.InteropServices
Microsoft.Extensions.DependencyInjection.Abstractions
System.Threading.Tasks
System.Threading.Tasks.4.0.11
Microsoft.Extensions.Logging.Abstractions
Microsoft.Extensions.Logging.Abstractions.1.0.0
Microsoft.Extensions.Logging
Microsoft.Extensions.Options
Microsoft.Extensions.Primitives
Remotion.Linq
Newtonsoft.Json
System.Collections
System.Collections.Immutable
System.Diagnostics.Debug
System.Diagnostics.DiagnosticSource
System.Collections.Concurrent
System.ComponentModel
System.Threading
.
I have created a new website in Azure and now it works, it seems that the previous website was deploying a previous application from Github and there were some conflicts, everything works fine now

TFS Can't Restore NuGet Package

I've got TFS doing some continuous integration builds. Today, it broke for one solution. It seems it can't find AutoMapper. All the other packages can be found just fine.
A couple relevant points:
None of the packages are in source control, we're letting TFS restore them.
We have an internal NuGet feed, but it doesn't seem to be a problem in other solutions, and in this solution we are still getting Entity Framework to restore - just not AutoMapper.
I tried removing and re-adding the NuGet Packages. No luck.
If I use Remote Desktop to connect to the build server and open the project in Visual Studio there, it restores the packages and builds fine.
I can build manually by executing D:\"Program Files"\"Microsoft Team Foundation Server 12.0"\Tools\Nuget.exe restore followed by msbuild MySolutoin.sln
Our TFS server is installed on our D:\ drive.
This is from the TFS Logs:
D:\Program Files\Microsoft Team Foundation Server 12.0\Tools\nuget.exe restore "C:\Builds\1\MyCompany Web\FclQuoteWcfService\src\FclQuoteWcfService.sln" -NonInteractive
Installing 'EntityFramework 6.1.3'.
Installing 'InternalPackage 1.0'.
Successfully installed 'InternalPackage 1.0'.
Successfully installed 'EntityFramework 6.1.3'.
Unable to find version '3.3.1' of package 'AutoMapper'.
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\MSBuild.exe /nologo /noconsolelogger "C:\Builds\1\MyCompany Web\FclQuoteWcfService\src\FclQuoteWcfService.sln" /nr:False /fl /flp:"logfile=C:\Builds\1\MyCompany Web\FclQuoteWcfService\src\FclQuoteWcfService.log;encoding=Unicode;verbosity=normal" /p:SkipInvalidConfigurations=true /m /p:OutDir="C:\Builds\1\MyCompany Web\FclQuoteWcfService\bin\\" /p:VCBuildOverride="C:\Builds\1\MyCompany Web\FclQuoteWcfService\src\FclQuoteWcfService.sln.vsprops" /dl:WorkflowCentralLogger,"D:\Program Files\Microsoft Team Foundation Server 12.0\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Normal;BuildUri=vstfs:///Build/Build/230;IgnoreDuplicateProjects=False;InformationNodeId=12;TargetsNotLogged=GetNativeManifest,GetCopyToOutputDirectoryItems,GetTargetPath;TFSUrl=http://ctidev2k8:8080/tfs/MyCompany;"*WorkflowForwardingLogger,"D:\Program Files\Microsoft Team Foundation Server 12.0\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Normal;" /p:BuildId="9aa9f8af-c9b9-4d0a-ba06-7cc959231d8e,vstfs:///Build/Build/230" /p:BuildLabel="FclQuoteWcfService_20150330.2" /p:BuildTimestamp="Mon, 30 Mar 2015 20:40:07 GMT" /p:BuildSourceVersion="LFclQuoteWcfService_20150330.2#$/MyCompany Web" /p:BuildDefinition="FclQuoteWcfService"
Exception Message: MSBuild error 1 has ended this build. You can find more specific information about the cause of this error in above messages. (type BuildProcessTerminateException) Exception Stack Trace: at System.Activities.Statements.Throw.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
I've seen this too. It seems to be triggered as soon as NuGet package restore switches to the internal feed. Once it does this is doesn't switch back to the official nuget.org feed and continues to look for the packages on the internal feed.
Ensure both package sources are added to your NuGet.config file. Also ensure both sources are 'active'.
<configuration>
<packageSources>
<add key="nuget.org"
value="https://www.nuget.org/api/v2/" />
<add key="example.com"
value="http://example.com/feed/nuget/" />
</packageSources>
<activePackageSource>
<add key="All"
value="(Aggregate source)" />
</activePackageSource>
</configuration>
See NuGet configuration file documentation.
Matt's answer put me on the right track but we don't use an internal feed so I had to do some more digging. This answer works, at least, for a project created in Visual Studio 2015 and built by TFS 2015.
In Visual Studio, open the NuGet package manager settings (Tools menu > NuGet Package Manager > Package Manager Settings). Choose "Package Sources" from the options list on the left.
Create the nuget.config file at the root of the solution. This should be the same folder location as your ".sln" solution file. Copy the following into the config file:
<configuration>
<packageSources>
</packageSources>
<activePackageSource>
<add key="All"
value="(Aggregate source)" />
</activePackageSource>
</configuration>
Within the <packageSources> tag, create an <add key="" value="" /> entry for each source listed in the "Package Sources" options window. The key is the name of the source as shown above the URL, and the value is the URL itself. Include those listed in both "Available package sources" and "Machine-wide package sources". I did not create an entry for the local filesystem as it wasn't used in this solution. Based on the screenshot above, the complete config file now contains the following:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org"
value="https://api.nuget.org/v3/index.json" />
<add key="Microsoft and .NET"
value="https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/" />
</packageSources>
<activePackageSource>
<add key="All"
value="(Aggregate source)" />
</activePackageSource>
</configuration>
After committing the nuget.config file to source control, TFS was able to download all the necessary NuGet packages and successfully build the solution.
In addition to Matt's answer, I'd like to highlight the following well-hidden stuff from the NuGet documentation:
NuGet config files are treated in the following priority order
(closest to the folder nuget.exe runs from wins), for example assuming
the solution directory is c:\a\b\c:
c:\a\b\c\.nuget\nuget.config - This file is only used for solution
level packages, and is not supported in nuget 3.0 - 3.4
c:\a\b\c\nuget.config
c:\a\b\nuget.config
c:\a\nuget.config
c:\nuget.config
User specific config file,
%AppData%\NuGet\nuget.config.
Or the user specified file thru option
-ConfigFile.
This could explain some weird behaviour in specific scenario's where a restore does or does not pick up a configured feed, depending on whether youre restoring with nuget 2.x or 3.x
Edit: and I found yet another reason why packages might not be detected:
I have package "A" with version 1.1.1.0 .
Prior 3.4 this command works well:
nuget install A -version 1.1.1.0
With NuGet 3.4 RC I get:
An error occurred while retrieving package metadata for 'A.1.1.1' from
source 'N'. An error occurred while retrieving package metadata for
'A.1.1.1' from source 'N'. Data at the root level is invalid. Line
1, position 1.
...
The client treats 1.1, 1.1.0, 1.01.0 and 1.1.0.0 as the same version
using SemVer rules. The reason non-normalized versions were special
cased in the past is because for v2 http calls the client would first
send the version string exactly as the user specified it

Build on TFS 2013 failed but okay locally

When I checked in the code, TFS 2013 built the solution automatically. It is okay in local VS 2013 but failed in TFS.
Here is the summary.
Summary
FTPProcessor | Any CPU
1 error(s), 56 warning(s)
$/xxxx/NewServiceHost/New-Branch/NewServiceHost/packageRestore.proj - 0 error(s), 0 warning(s)
$/xxxx/NewServiceHost/New-Branch/GenericWindowsServices.sln - 1 error(s), 56 warning(s)
C:\Builds\1\xxxx\FTP Processor (New)\src\.nuget\nuget.targets (71): The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Build.Tasks.v4.0.dll". Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Build.Tasks.v4.0.dll' or one of its dependencies. The system cannot find the file specified.
Other Errors
1 error(s)
Exception Message: MSBuild error 1 has ended this build. You can find more specific information about the cause of this error in above messages. (type BuildProcessTerminateException) Exception Stack Trace: at System.Activities.Statements.Throw.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
Your TFS 2013 build server is using MSBuild 12.0 where CodeTasksFactory exists in Microsoft.Build.Tasks.v12.0.dll rather than Microsoft.Build.Tasks.v4.0.dll.
Ideally you should be doing the following:
1) Open your NuGet.targets file:
C:\Builds\1\xxxx\FTP Processor (New)\src.nuget\nuget.targets
2) Identify the task referencing the old DLL.
<UsingTask AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" TaskFactory="CodeTaskFactory" >
...
3) Then future proof it like so:
<UsingTask AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v$(MSBuildToolsVersion).dll" TaskFactory="CodeTaskFactory" >
...
As of VS2013,
you should be running MSBuild from C:\Program Files (x86)\MSBuild\12.0\Bin\
not from C:\Windows\Microsoft.NET\Framework64\v4.0.30319. See
http://blogs.msdn.com/b/visualstudio/archive/2013/07/24/msbuild-is-now-part-of-visual-studio.aspx
source:http://gyorgybalassy.wordpress.com/2013/12/31/msb4175-the-task-factory-codetaskfactory-could-not-be-loaded/
it solved the issue for me.
After much research and trying a bunch of "hacks" I went on to understand the exact mechanics of nuget restore. It turns out, everything has changed since nuget 2.7+ and you're no longer required to include ".nuget" folder and the associated nuget.exe and nuget.target
To fix my build process and use the latest recommended approach, I did the following:
Move nuget.config to be with .sln file same folder path
Delete ".nuget" folder entirely
Delete references to that folder in .sln file
Delete following lines from any .csproj file
--
<RestorePackages>true</RestorePackages>
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
--
This could take some time if your project solution has many files or you work on many projects built with Visual Studio 2013 and before.
The good news is, there's a powershell script that applies the above recursively on any folder:
https://github.com/owen2/AutomaticPackageRestoreMigrationScript/blob/master/migrateToAutomaticPackageRestore.ps1
In short, it reverses "Enable Nuget Package Restore", allowing the
newer package restore method to work.
In Visual Studio 2013, automatic package restore became part of the
IDE (and the TFS build process). This method is more reliable than the
older, msbuild integrated package restore. It does not require you to
have nuget.exe checked in to each solution and does not require any
additional msbuild targets. However, if you have the files related to
the old package restore method in your project, Visual Studio will
skip automatic package restore. (This behavior is likely to change
soon, hopefully it does).
You can use this script to remove nuget.exe, nuget.targets, and all
project and solution references to nuget.targets so you can take
advantage of Automatic Package Restore. It more or less automates the
process described here.
It will recurse through the directory you run the script from and do
it to any solutions that may be in there somewhere. Be careful and
have fun! (not responsible for anything that breaks)
A couple of good links on the subject:
http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html
http://docs.nuget.org/consume/package-restore/migrating-to-automatic-package-restore
I had a similar issue. We are forced into using the older msbuild that comes with the framework, rather than the v14 version that comes with visual studio 2015 because we build some old Delphi.net code. Our vcxproj files are triggering some automatic code analysis target which has a task that relies on Microsoft.Build.Tasks.v12.0.dll. I was able to override that task by copying and pasting it into the top of the vcxproj and tweaking the path to the dll. The original task can be found in "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.Targets". So, in other words, you might be able to override the problem task in your project.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- override a task which we can't use with the old msbuild -->
<UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<EnvKey ParameterType="System.String" Required="true" />
<EnvValue ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
Environment.SetEnvironmentVariable(EnvKey, EnvValue, System.EnvironmentVariableTarget.Process);
}
catch {
}
]]>
</Code>
</Task>
</UsingTask>

TFS 2012 build error The "CreateWorkspaceTask" task was not given a value for the required parameter "BuildAgentUri"

We upgraded to TFS 2012 and changed our legacy build templates to remove all strong name references to Microsoft.TeamFoundation namespaces from the Activity element. We are now getting the following error when building:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets (801): The "CreateWorkspaceTask" task was not given a value for the required parameter "BuildAgentUri".
Has anyone else encountered this error?
I just resolved this issue earlier today....
Navigate and open:-
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets
Find the section resembling the following:-
CreateWorkspaceTask
TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
BuildDirectory="$(BuildDirectory)"
SourcesDirectory="$(SolutionRoot)"
Name="$(WorkspaceName)"
Comment="$(CreateWorkspaceTaskComment)"
Replace it with:-
<!-- Create the workspace for this build -->
<CreateWorkspaceTask
TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
BuildDirectory="$(BuildDirectory)"
SourcesDirectory="$(SolutionRoot)"
Name="$(WorkspaceName)"
Comment="$(CreateWorkspaceTaskComment)"
Condition=" '$(ProjectFileVersion)' != '4'">
<Output TaskParameter="Name" PropertyName="WorkspaceName" />
<Output TaskParameter="Owner" PropertyName="WorkspaceOwner" />
</CreateWorkspaceTask>
<CreateWorkspaceTask
TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
BuildDirectory="$(BuildDirectory)"
BuildAgentUri="$(BuildAgentUri)"
SourcesDirectory="$(SolutionRoot)"
Name="$(WorkspaceName)"
Comment="$(CreateWorkspaceTaskComment)"
Condition=" '$(ProjectFileVersion)' == '4'">
<Output TaskParameter="Name" PropertyName="WorkspaceName" />
<Output TaskParameter="Owner" PropertyName="WorkspaceOwner" />
</CreateWorkspaceTask>
Please pay special attention to the casing of the text as this is an XML document...
Please let me know if this helps...
Cheers!
...
Chev
We ran into this same issue on one of our build machines. The build machine was working fine one day and stopped the next. The only change was finishing the installation of Service Pack 1 for Visual Studio 2010.
We figured that possibly MSBuild got rolled to a previous version.
So we looked at this file on another build machine and that section looked exactly like the snippet Chev provided.
So we went into "progams and features" on the build machine and did a Repair on the TFS 2012 installation. That updated the Microsoft.TeamFoundation.Build.targets file to look just like the snippet provided by Chev.
Now the builds run correctly again.

Resources