This question was asked a while ago but it pertains to the same type of issue I was having.
The Problem:
- We want to check in our code.
- We then want build our project.
- During our build we depend on Build Events to move files around so we have the proper files in place for the build process to complete.
- When our Build Event tries to copy the files, we get Access Denied errors.
The Reason:
- Team Foundation Server Visual Studio Plugin changes the Read Only attribute on our files to READONLY TRUE when we check in our files.
Build Event Example:
- copy "$(TargetDir)SomeFile.ext" "$(ProjectDir)"
Above, we simply need to move a file from our Target Build Path (the bin\debug or bin\release folders) to our Project Folder. In my situation, this was so I could include project built files in my installer. My Installer wasn't grabbing them as part of the Project Output.
The Fix: (nearly kicked my self in the face when I figured this out)
New Build Event:
- attrib -R "$(ProjectDir)SomeFile.ext"
- copy "$(TargetDir)SomeFile.ext" "$(ProjectDir)"
- attrib +R "$(ProjectDir)SomeFile.ext"
We're all having fun with Build Events right? Above I simply do 2 things, I remove the read only attribute, now the files not read only. Copy my file as I was originally wanting to. Then replace the Read Only Attribute (optional I guess) to keep Visual Studio and Team Foundations happy.
And yes... I'm still kicking myself in the face on this one.