I think I have actually seen this error in other versions of TFS besides 2010, but most recently saw it in 2010 deployment. Post-executing build configuration when running a build for something using Web Application projects you might receive the error:
The imported project “C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets” was not found
To solve this issue, just copy the C:\Program Files\MSBuild\Microsoft\Visual Studio\v10.0\WebApplications directory from a development machine to the build machine. Sucks but it works. Seems sporadic why it happens.
During testing of my recent TFS migration we found a small issue with a SharePoint Application Page build that had some embedded Silverlight in it where the ClientBin directory was not being created by TeamBuild.
The error looks similar to the following:
MSBuild\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets(60,3): error MSB3021: Unable to copy file “ClientBin\Base.Silverlight..xap” to “\“. Could not find a part of the path ‘ClientBin\.xap’.
So why does this happen? There could be a couple reasons you might be running into this particular error, the largest of which is the default settings of TFS not checking in the XAP files. Which doesn’t make a ton of sense. Also, you will generally run into this error when a Siliverlight project is renamed and its parent directory is renamed. Which of these causing the error will determine the appropriate resolution path.
If you are running into this because you think you are hitting the renaming error, then the easiest way to fix it is to unload the project, edit .csproj, and correct the values in the tag. After you perform a check-in and start a build the error will go away. If you are not entirely sure why it is happening and the aforementioned renaming doesn’t sound like your issue, then you can implement a couple of other things to get around the problem.
Firstly, change the referring Content item in the xap file:
.xap” Condition=”$(IsDesktopBuild) != true” />
Following, in the AfterDropBuild Target, execute a manual copy of the xap to the _PublishedWebsites folder: