VsTac 任务失败,使用全局 Cordova 工具集时找不到文件 appAsTgz.tgz

VsTac task failed, could not find file appAsTgz.tgz when using global Cordova toolset

当我使用全局安装的 Cordova 7.1.0 工具集并执行 iOS 远程构建(到模拟器或本地设备)时,我几乎立即收到错误消息:

Error   MSB4018 The "VsTac" task failed unexpectedly.
System.IO.FileNotFoundException: Could not find file 'C:\Users\joe\AppData\Local\Temp\appAsTgz.tgz'.
File name: 'C:\Users\joe\AppData\Local\Temp\appAsTgz.tgz'
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode)
   at Microsoft.VisualStudio.MultiDeviceHybridApps.MdaBuildTasks.RemoteBuild.AppAsTgzStream(String changeTimeFile, JObject lastChangeTimesMap)
   at Microsoft.VisualStudio.MultiDeviceHybridApps.MdaBuildTasks.RemoteBuild.Build()
   at Microsoft.VisualStudio.MultiDeviceHybridApps.MdaBuildTasks.VsTac.BuildPlatform()
   at Microsoft.VisualStudio.MultiDeviceHybridApps.MdaBuildTasks.VsTac.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() MyFleetGoTest   C:\Program Files (x86)\Microsoft Visual Studio17\Professional\MSBuild\Microsoft\VisualStudio\v15.0\ApacheCordovaTools\vs-mda-targets\Microsoft.MDA.FileMirroring.targets 256 

我可以构建 iOS 和 Android 浏览器。我可以将工具集更改为 <vs:toolsetVersion>6.3.1</vs:toolsetVersion>,错误消失,消息成功。

是否可以使用全局 Cordova 7.1.0 安装而不是 VS TACO 6.3.1 工具集并开始工作 iOS 远程构建?这是 Visual Studio 2017.

是的,这是可能的,直到今天我都能够在没有太多问题的情况下做到这一点,但是今天我遇到了你提到的问题,我花了一整天的时间试图解决它。

不幸的是,我不能确切地说出是什么原因造成的,因为我在更新以使用 wkwebview for IOS(顺便说一句,我正在使用 Ionic 框架)之后一直在尝试解决 CORS 问题。

在尝试各种操作后,我现在已经解决了这个问题,例如安装 Visual Studio 的最新更新,尝试将 Node.js 升级到最新版本(然后我不得不恢复到最新版本6.12.0 由于 node-sass).

的问题

再次很难说到底是什么解决了这个问题,因为我今天花了几个小时在恐慌中尝试各种方法来解决这个问题,但我认为解决方案是:

  1. 删除我项目中的node_modules
  2. 运行 npm install 重建 node_modules 文件夹
  3. 我还必须 运行 npm install -g cordova@latest

这是由于 NPM 5.5 中的一个错误。我相当确定它与此错误有关:

https://github.com/npm/npm/issues/17858

我安装了 NodeJS 6.*(而不是最新的 LTS 8.*),问题消失了。重新安装 8.* 会导致问题再次出现。

使用 Cordova 和 Visual Studio 2017 (15.5)

为 iOS 编译的最新方法

在Mac OS:

  • 安装Xcode9.*

  • 安装Node.JS6.*。 (https://nodejs.org/dist/latest-v6.x/) - 较新的 NPM 版本暂时无法使用。

  • 通过终端安装Xcode组件: xcode-select--安装

  • 安装 "remotebuild" Microsoft 工具,用于从 Visual Studio (Windows) 进行远程编译: sudo npm install -g remotebuild

  • 安装 COCOA Pods(较新的 Cordova 7.1.0 需要): sudo gem 安装 cocoapods

  • 设置 COCOA Pods 首次使用只需 运行 命令(下载约 680 MB): 广告连播设置

- 设置权限:

sudo chown -R $USER:$GROUP ~/.npm

sudo chown -R $USER:$GROUP ~/.config

  • 启动remotebuild开始监听: 远程构建

在Windows中:

来自

<vs:toolsetVersion>6.3.1</vs:toolsetVersion>

<vs:toolsetVersion>GlobalCordovaVersion</vs:toolsetVersion>

  • 从 config.xml 中删除以下行(使用 xml 编辑器打开):

<engine name="android" spec="5.2.1" /> //if the file has another line with a newer version

<engine name="ios" spec="4.2.0" /> //if the file has another line with a newer version

<engine name="windows" spec="4.4.2" /> //if the file has another line with a newer version

<preference name="windows-target-version" value="10.0" /> //if the file has another line with a newer version

  • 设置 Visual Studio(工具 > 选项 > Apache Cordova 工具)使用 remotebuild 生成的配置(运行 in Mac OS ).屏幕示例: Remote Agent Output

    • 提示:在配置前尝试 ping。如果您遇到问题,请使用 IP 代替计算机名称。
  • 构建。您可以在 bin\iOS\Debug 文件夹中找到您的 *.ipa 文件。