1 minute read

So here is kind of a weird situation. You create your first Cordova application in Visual Studio 2015, hurrah! Naturally, you may be using TFS. You have your solution checked into source control (remember to exclude the platforms folder). Everything is going fine so you check in your source. Great! Oh wait, you need to make more changes. So you check out your project and start making modifications then try to build. Build failed! You get an error in the clean.bat inside the platforms folder. It turns out, that entire folder is marked as Read-Only. But, you didn’t check it in to TFS! Yep, it is still Read-Only for some reason. So in order to build you have to do a clean solution then build. Pretty annoying right? Here is something you can do to get around it. Remove the Read-Only flag!

  • Right click the project and choose unload project.
  • Right click the project file and click edit project file.
  • At the top, add a new target named “Before Build” like this:
<Project ToolsVersion="14.0" DefaultTargets="BeforeBuild;Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  • Then at the bottom of the file, you have to add a the new target as a section like this:
<Target Name="BeforeBuild">
  <Exec Command="attrib -R &quot;$(SolutionDir)YourProjectName\platforms\*.*&quot; /S" IgnoreExitCode="true" />
</Target>

And that should do it for you. Now, before you build it will remove the Read-Only flag from the entire platforms directory and sub files which will allow them to be overwritten.