I’m working on a TFS project where the previous developers have included everything in source control – including the bin and obj folders.
When I try to build the solution, I get a few errors because all of the files in the bin and obj folder are locked as read only.
For reasons I can’t control, these folders have to be tracked in TFS. How else can I fix the problems caused when I try to build the project and get errors because these folders are locked?
How can I build the solution without checking out these folders every single time?
As previously mentioned, there is no reason to have have bin and obj folders included in source control, their contents are volatile.
But if you really have no control over that, you simply need to make the appropriate folders and files writeable so they can be overwritten, or delete the bin and obj folders after making them writeable. This is relatively straightfoward, there are a couple of ways to achieve it, and it requires changing the TFSBuild.proj file for the appropriate build.
To make a specific file writable, use this:
For making the contents of a whole folder writable, use batching to get a list of the files, then iterate over them using the
attribtask:Alternatively you can execute a Delete on the bin folder:
With the exception of the batching example, these tasks can be placed directly within the
BeforeCompileSolutionoverride target of the build proj file; for the batching example you simply do a call target. Pick and choose which method you want to use, then yourBeforeCompileSolutionwill look something like this: