First question is why are you editing source-controlled files as part of the build? Do you intend to check-in the changes as part of the build also?
You will need to update the build (either the TFS Workflow, or your MSBuild Targets) to Check-Out the files from TFS before attempting to modify them (or simply turn-off the Read-Only flag), then either Check-In when done modifying them or Undo Checkout on them.