Apache Cordova 构建工具在 TFS 上失败

Tools for Apache Cordova Builds Fail on TFS

我在 TFS 2013 上构建 Cordova 应用程序时遇到错误。具体来说,它总是无法对特定于平台的 screen.png 文件执行某种操作。其他帖子讨论了与被标记为只读的文件相关的问题,但我一直无法使用我发现的使构建工作的少数解决方案中的任何一个。有什么想法吗?

...
                     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)

您需要检查以下事项:

  1. 确保 "screen.png" 的路径未设置为 "Read-Only"。
  2. 确保构建服务使用的帐户有足够的权限访问该文件。 (尝试 运行 使用管理员帐户构建服务)

如果还是不行,尝试在构建前添加一个检出文件的步骤。同样的问题可以参考这里:https://social.msdn.microsoft.com/Forums/vstudio/en-US/81d5e57c-49bd-4487-a198-7930b48412b5/error-building-windows-x64-windows-x86-or-windows-anycpu

我终于找到了解决办法。我添加了一个 before_prepare 挂钩以从文件中删除只读标志。我添加了包含以下内容的文件 hooks/before_prepare/undoReadOnly.bat。请注意,我必须在 Visual Studio 之外编辑它们并使用 ANSI 编码保存它们以便 TFS 能够读取它们:

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