Avoiding the infamous locked .xap file when building Silverlight projects in TFS
Building Silverlight projects on the Team Foundation Server Build Agent can get messy when you have .xap files around. We stumbled across this issues with a colleague from work (Dani you know, that was you
) when automating the build agent for a client.
The solution is quite simple, even if not intuitive. What we need to do is to deny the build agent read access to the file avoiding to download it in the first place. So as the download process do not fail, we can perform the build without trying to overwrite a locked file.
Hope this helps.

Great post ! But how can i deny access to the specific file?
@Dave Smits
Good question, I was in a hurry but I saw that question coming
. You just need to open the source code in the Team Explorer being an administrator, right-click in the file and open the security tab. You will notice your build agent security permissions, select it and deny the read access.
[...] digging around the net today, I found an article that saved the day. Thanks Corvalius! Here is the solution I implemented to resolve the [...]
Sorry, to bug, but I could not find an entry to my Build Agent in security. Just an entry for Build Services. I also checked on Buld services and it has no members. So, I am still puzzled how to deny access to the build Agent using the Security Tab.
@Joe Jo
Hi Joe,
If you have entered the security tab from the .xap file, you just need to set Deny to you “Build Services” (that is the build agent name).
Greetings
Federico
[...] found the tip for the solution here. Published Friday, April 30, 2010 9:02 AM by jdanforth Filed under: VS2010, TFS, [...]
[...] I found the tip for the solution here. [...]