From 36b276620a30d24e6db88c453f234aafbee7989d Mon Sep 17 00:00:00 2001 From: Kota Iguchi Date: Wed, 9 Aug 2017 19:45:44 +0900 Subject: [PATCH] [TIMOB-25077] Unable to compile with VS2017 --- windows/plugins/hooks/hyperloop.js | 41 ++++++++++++++++-------- windows/sdk_plugins/windows/hyperloop.js | 6 ++-- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/windows/plugins/hooks/hyperloop.js b/windows/plugins/hooks/hyperloop.js index 813e05b8..0e677a52 100644 --- a/windows/plugins/hooks/hyperloop.js +++ b/windows/plugins/hooks/hyperloop.js @@ -5,6 +5,10 @@ var spawn = require('child_process').spawn, ejs = require('ejs'), appc = require('node-appc'); +function isVS2017(data) { + return /^Visual Studio \w+ 2017/.test(data.windowsInfo.selectedVisualStudio.version); +} + exports.cliVersion = ">=3.2"; exports.init = function(logger, config, cli, nodeappc) { /* @@ -21,19 +25,27 @@ exports.init = function(logger, config, cli, nodeappc) { function(next) { runCmake(data, 'WindowsStore', 'ARM', '10.0', next); }, - function(next) { + ]; + + var w81support = !isVS2017(data); + + // Visual Studio 2017 doesn't support Windows/Phone 8.1 project anymore + if (w81support) { + tasks.push(function(next) { runCmake(data, 'WindowsPhone', 'Win32', '8.1', next); - }, - function(next) { + }); + tasks.push(function(next) { runCmake(data, 'WindowsPhone', 'ARM', '8.1', next); - }, - function(next) { + }); + tasks.push(function(next) { runCmake(data, 'WindowsStore', 'Win32', '8.1', next); - }, - ]; + }); + } + + var archs = w81support ? ['phone', 'store', 'win10'] : ['win10']; var csharp_dest = path.join(data.projectDir, 'reflection', 'HyperloopInvocation'); - ['phone', 'store', 'win10'].forEach(function(platform) { + archs.forEach(function(platform) { ['Debug', 'Release'].forEach(function(buildConfig) { tasks.push( function(next) { @@ -53,7 +65,10 @@ exports.init = function(logger, config, cli, nodeappc) { * Copy dependencies */ cli.on('build.module.pre.package', function (data, callback) { - ['phone', 'store', 'win10'].forEach(function(platform){ + var w81support = !isVS2017(data), + archs = w81support ? ['phone', 'store', 'win10'] : ['win10']; + + archs.forEach(function(platform){ ['ARM', 'x86'].forEach(function(arch){ var from = path.join(data.projectDir, 'reflection', 'HyperloopInvocation', 'bin', platform, 'Release'), to = path.join(data.projectDir, 'build', 'Hyperloop', data.manifest.version, platform, arch); @@ -97,7 +112,7 @@ function generateCMakeList(data, next) { function runCmake(data, platform, arch, sdkVersion, next) { var logger = data.logger, - generatorName = 'Visual Studio 14 2015' + (arch==='ARM' ? ' ARM' : ''), + generatorName = (isVS2017(data) ? 'Visual Studio 15 2017' : 'Visual Studio 14 2015') + (arch==='ARM' ? ' ARM' : ''), cmakeProjectName = (sdkVersion === '10.0' ? 'Windows10' : platform) + '.' + arch, cmakeWorkDir = path.resolve(__dirname,'..','..',cmakeProjectName); @@ -184,9 +199,9 @@ function runMSBuild(data, slnFile, buildConfig, callback) { logger.debug('Running MSBuild on solution: ' + slnFile); // Use spawn directly so we can pipe output as we go - var p = spawn(vsInfo.vcvarsall, [ - '&&', 'MSBuild', '/p:Platform=Any CPU', '/p:Configuration=' + buildConfig, slnFile - ]); + var p = spawn((process.env.comspec || 'cmd.exe'), ['/S', '/C', '"', vsInfo.vsDevCmd.replace(/[ \(\)\&]/g, '^$&') + + ' && MSBuild /p:Platform="Any CPU" /p:Configuration=' + buildConfig + ' ' + slnFile + '"' + ], {windowsVerbatimArguments: true}); p.stdout.on('data', function (data) { var line = data.toString().trim(); if (line.indexOf('error ') >= 0) { diff --git a/windows/sdk_plugins/windows/hyperloop.js b/windows/sdk_plugins/windows/hyperloop.js index 5c9af984..ef690cb8 100644 --- a/windows/sdk_plugins/windows/hyperloop.js +++ b/windows/sdk_plugins/windows/hyperloop.js @@ -318,9 +318,9 @@ exports.cliVersion = '>=3.2'; logger.debug('Running MSBuild on solution: ' + slnFile + ' for ' + buildConfiguration); // Use spawn directly so we can pipe output as we go - var p = spawn(vsInfo.vcvarsall, [ - '&&', 'MSBuild', '/p:Platform=Any CPU', '/p:Configuration=' + buildConfiguration, slnFile - ]); + var p = spawn((process.env.comspec || 'cmd.exe'), ['/S', '/C', '"', vsInfo.vsDevCmd.replace(/[ \(\)\&]/g, '^$&') + + ' && MSBuild /p:Platform="Any CPU" /p:Configuration=' + buildConfiguration + ' ' + slnFile + '"' + ], {windowsVerbatimArguments: true}); p.stdout.on('data', function (data) { var line = data.toString().trim(); if (line.indexOf('error ') >= 0) {