Considerations When Using TFS for SharePoint And Silverlight Development

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: