Search code examples
androidcordovatfsbuildhybrid-mobile-appvisual-studio-cordova

Tools for Apache Cordova Builds Fail on TFS


I'm receiving errors building a Cordova app on TFS 2013. Specifically, it always fails doing some sort of operation on a platform-specific screen.png file. Other posts talk about the problem being related to the file being marked as read-only, but I've been unable to use any of the few solutions I found to get the build to work. Any ideas?

...
                     Install complete for cordova-plugin-customurlscheme on android. (TaskId:12)
                     Executing "after_plugin_install"  hook for "cordova-plugin-customurlscheme" on android. (TaskId:12)
                     Searching PlatformJson files for differences between project vs. platform installed plugins (TaskId:12)
                     No differences found between project and android platform. Continuing... (TaskId:12)
                     Generating config.xml from defaults for platform "android" (TaskId:12)
                     Wrote out Android application name to "My App" (TaskId:12)
15:10:15.163     2>MDAVSCLI : error : EPERM, operation not permitted 'D:\Builds\Cordova\MyApp\src\MyApp\platforms\android\res\drawable-land-hdpi\screen.png' [D:\Builds\Cordova\MyApp\src\MyApp\MyApp.jsproj]
                   Done executing task "MdaVsCli" -- FAILED. (TaskId:12)

Solution

  • I finally found a solution. I added a before_prepare hook to remove the read only flag from the files. I added the file hooks/before_prepare/undoReadOnly.bat with the contents below. Note that I had to edit these outside of Visual Studio and save them with ANSI encoding for TFS to be able to read them:

    echo before_prepare hook - undoReadOnly
    echo MSBuildProjectDirectory=%MSBuildProjectDirectory%
    attrib -r %MSBuildProjectDirectory%\MyApp\platforms\*.* /S /D