Visual Studio 2015无法为Cordova项目创建发布版本

时间:2016-01-08 10:23:54

标签: visual-studio cordova visual-studio-2015 uwp visual-studio-cordova

我正在使用Visual Studio 2015 for Cordova Tools构建一个针对Windows Universal(UWP)和Android的应用程序。

我可以为Android和UWP成功创建调试版本,也可以为Android发布版本。

但是,Visual Studio无法为UWP创建发布版本,<!DOCTYPE html> <html> <body> <?php class Connection { protected $host = "localhost"; protected $dbname = "addressbook"; protected $user = "root"; protected $pass = ""; protected $conn; function __construct() { try { $this->conn = new PDO("mysql:host=$this->host;dbname=$this->dbname", $this->user, $this->pass); } catch (PDOException $e) { echo $e->getMessage(); } } public function closeConnection() { $this->conn = null; } } class querys extends Connection{ public function adres_book{ $sql = "SELECT * FROM tb_address_book"; $sql = $this->conn->prepare($sql); $sql->execute(); return $sql->fetchAll(); } } $conn = new Connection(); $query = new querys(); ?> On the php file: <?php Foreach($query->adres_book() as $db_field){ print $db_field['ID'] . "<BR>"; print $db_field['First_Name'] . "<BR>"; print $db_field['Surname'] . "<BR>"; print $db_field['Address'] . "<BR>"; } ?> </body> </html> Windows-AnyCPUWindows x86Windows x64选项均无效。

Windows ARM创建发布版本时,错误消息如下:

Windows-AnyCPU

1>C:\Program Files (x86)\MSBuild\Microsoft\.NetNative\Microsoft.NetNative.targets(133,5): error MSB3779: The processor architecture of the project being built "Any CPU" is not supported by the referenced SDK "Microsoft.NET.Native.Framework.1.2, Version=1.2". Please consider changing the targeted processor architecture of your project (in Visual Studio this can be done through the Configuration Manager) to one of the architectures supported by the SDK: "x86, x64, ARM". [C:\Users\ztl87\Documents\Visual Studio 2015\Projects\UnihanHelper\UnihanHelper\platforms\windows\CordovaApp.Windows10.jsproj] 1>C:\Program Files (x86)\MSBuild\Microsoft\.NetNative\Microsoft.NetNative.targets(133,5): error MSB3779: The processor architecture of the project being built "Any CPU" is not supported by the referenced SDK "Microsoft.NET.Native.Runtime.1.1, Version=1.1". Please consider changing the targeted processor architecture of your project (in Visual Studio this can be done through the Configuration Manager) to one of the architectures supported by the SDK: "x86, x64, ARM". [C:\Users\ztl87\Documents\Visual Studio 2015\Projects\UnihanHelper\UnihanHelper\platforms\windows\CordovaApp.Windows10.jsproj] 1>C:\Program Files (x86)\MSBuild\Microsoft\.NetNative\Microsoft.NetNative.targets(248,5): error MSB4062: The "IlcErrorTask" task could not be loaded from the assembly C:\Program Files (x86)\MSBuild\Microsoft\.NetNative\x86\ilc\ilc.exe. Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\Microsoft\.NetNative\x86\ilc\ilc.exe' or one of its dependencies. An attempt was made to load a program with an incorrect format. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [C:\Users\ztl87\Documents\Visual Studio 2015\Projects\UnihanHelper\UnihanHelper\platforms\windows\CordovaApp.Windows10.jsproj] 1>MDAVSCLI : error : Error code 1 for command: C:\Program Files (x86)\MSBuild\14.0\bin\amd64\msbuild with args: C:\Users\ztl87\Documents\Visual Studio 2015\Projects\UnihanHelper\UnihanHelper\platforms\windows\CordovaApp.Windows10.jsproj,/clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal,/nologo,/p:Configuration=release,/p:Platform=anycpu 1> Command finished with error code 2: cmd /s /c ""C:\Users\ztl87\Documents\Visual Studio 2015\Projects\UnihanHelper\UnihanHelper\platforms\windows\cordova\build.bat" --release "--buildConfig=C:\Users\ztl87\Documents\Visual Studio 2015\Projects\UnihanHelper\UnihanHelper\build.json" --archs=anycpu --win" 1>ERROR building one of the platforms : error : cmd: Command failed with exit code 2 1> You may not have the required environment or OS to build this project 1>MDAVSCLI : error : cmd: Command failed with exit code 2 Windows x86Windows x64创建发布版本时,错误消息如下:

Windows ARM

令我困惑的是,所有这4种配置都适用于 Debug 版本。

此外,当我尝试将应用与Windows应用商店相关联时,Visual Studio停止工作。

我正在使用:

  • Visual Studio Community 2015版本14.0.24720.00 Update 1
  • 适用于Apache Cordova的Visual Studio工具14.0.51016.1
  • Cordova CLI版本 5.4.1

我尝试重新安装Visual Studio,但它没有用。

感谢。

3 个答案:

答案 0 :(得分:5)

我花了好几个小时努力解决这个问题,最后通过卸载Node 64 bit并安装32位来解决它。

答案 1 :(得分:1)

您可以在中指定要构建Windows应用程序的体系结构和平台。

cordova build --release windows --appx=[platform] --archs=[architecture]

选项:

  • 平台:8.1-win,8.1-phone,uap
  • 架构:x86,x64,arm

例如:

cordova build --release windows --appx=uap --archs=arm

参考:https://cordova.apache.org/docs/en/latest/guide/platforms/win8/

答案 2 :(得分:0)

  

当我尝试将应用程序与Windows应用商店关联时,Visual Studio停止工作。

这是一个刚刚在Visual Studio 2015 Update 2中修复的错误。以下是安装程序的链接:http://go.microsoft.com/fwlink/?LinkId=691129