From 9499a1d3b2f07a984e1dea233623cb06d8a47e6f Mon Sep 17 00:00:00 2001 From: CanHua Li Date: Fri, 20 Dec 2019 14:27:28 -0800 Subject: [PATCH 1/4] check UAP in SDK10 installation folder --- .../runWindows/utils/msbuildtools.js | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/vnext/local-cli/runWindows/utils/msbuildtools.js b/vnext/local-cli/runWindows/utils/msbuildtools.js index a45d78dbed2..802f7f9a87a 100644 --- a/vnext/local-cli/runWindows/utils/msbuildtools.js +++ b/vnext/local-cli/runWindows/utils/msbuildtools.js @@ -20,6 +20,7 @@ const { newSuccess, newError, } = require('./commandWithProgress'); +const execSync = require('child_process').execSync; const MSBUILD_VERSIONS = ['16.0', '15.0', '14.0', '12.0', '4.0']; @@ -244,6 +245,27 @@ module.exports.findAvailableVersion = function(buildArch, verbose) { return msbuildTools; }; +function getSDK10InstallationFolder() { + const folder = ''; + + const execString = + 'reg query "HKLM\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v10.0" /s /v InstallationFolder /reg:32'; + let output; + try { + output = execSync(execString).toString(); + } catch (e) { + return folder; + } + + const re = /\\Microsoft SDKs\\Windows\\v10.0\s*InstallationFolder\s+REG_SZ\s+(.*)/gim; + const match = re.exec(output); + if (match) { + return match[1]; + } + + return folder; +} + module.exports.getAllAvailableUAPVersions = function() { const results = []; @@ -254,13 +276,22 @@ module.exports.getAllAvailableUAPVersions = function() { return results; } - const uapFolderPath = path.join( + let uapFolderPath = path.join( programFilesFolder, 'Windows Kits', '10', 'Platforms', 'UAP', ); + + if (!shell.test('-e', uapFolderPath)) { + // Check other installation folder from reg + const sdkFolder = getSDK10InstallationFolder(); + if (sdkFolder) { + uapFolderPath = path.join(sdkFolder, 'Platforms', 'UAP'); + } + } + // No UAP SDK exists on this machine if (!shell.test('-e', uapFolderPath)) { return results; From 46a5105c4eaf3790dad139f7abdf68e9cc73490a Mon Sep 17 00:00:00 2001 From: CanHua Li Date: Fri, 20 Dec 2019 14:28:12 -0800 Subject: [PATCH 2/4] Change files --- .../react-native-windows-2019-12-20-14-28-11-master.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 change/react-native-windows-2019-12-20-14-28-11-master.json diff --git a/change/react-native-windows-2019-12-20-14-28-11-master.json b/change/react-native-windows-2019-12-20-14-28-11-master.json new file mode 100644 index 00000000000..3bbf0606731 --- /dev/null +++ b/change/react-native-windows-2019-12-20-14-28-11-master.json @@ -0,0 +1,8 @@ +{ + "type": "none", + "comment": "supports SDK installed in other folder", + "packageName": "react-native-windows", + "email": "licanhua@live.com", + "commit": "9499a1d3b2f07a984e1dea233623cb06d8a47e6f", + "date": "2019-12-20T22:28:11.758Z" +} \ No newline at end of file From f2281ad54774fcd2fef9fc45cf1cb9be1e51bd97 Mon Sep 17 00:00:00 2001 From: CanHua Li Date: Fri, 20 Dec 2019 14:27:28 -0800 Subject: [PATCH 3/4] check UAP in SDK10 installation folder --- .../runWindows/utils/msbuildtools.js | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/vnext/local-cli/runWindows/utils/msbuildtools.js b/vnext/local-cli/runWindows/utils/msbuildtools.js index a45d78dbed2..802f7f9a87a 100644 --- a/vnext/local-cli/runWindows/utils/msbuildtools.js +++ b/vnext/local-cli/runWindows/utils/msbuildtools.js @@ -20,6 +20,7 @@ const { newSuccess, newError, } = require('./commandWithProgress'); +const execSync = require('child_process').execSync; const MSBUILD_VERSIONS = ['16.0', '15.0', '14.0', '12.0', '4.0']; @@ -244,6 +245,27 @@ module.exports.findAvailableVersion = function(buildArch, verbose) { return msbuildTools; }; +function getSDK10InstallationFolder() { + const folder = ''; + + const execString = + 'reg query "HKLM\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v10.0" /s /v InstallationFolder /reg:32'; + let output; + try { + output = execSync(execString).toString(); + } catch (e) { + return folder; + } + + const re = /\\Microsoft SDKs\\Windows\\v10.0\s*InstallationFolder\s+REG_SZ\s+(.*)/gim; + const match = re.exec(output); + if (match) { + return match[1]; + } + + return folder; +} + module.exports.getAllAvailableUAPVersions = function() { const results = []; @@ -254,13 +276,22 @@ module.exports.getAllAvailableUAPVersions = function() { return results; } - const uapFolderPath = path.join( + let uapFolderPath = path.join( programFilesFolder, 'Windows Kits', '10', 'Platforms', 'UAP', ); + + if (!shell.test('-e', uapFolderPath)) { + // Check other installation folder from reg + const sdkFolder = getSDK10InstallationFolder(); + if (sdkFolder) { + uapFolderPath = path.join(sdkFolder, 'Platforms', 'UAP'); + } + } + // No UAP SDK exists on this machine if (!shell.test('-e', uapFolderPath)) { return results; From 0164480fbb93b651bd606afd6010bc9735285c00 Mon Sep 17 00:00:00 2001 From: CanHua Li Date: Fri, 20 Dec 2019 14:28:12 -0800 Subject: [PATCH 4/4] Change files --- .../react-native-windows-2019-12-20-14-28-11-master.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 change/react-native-windows-2019-12-20-14-28-11-master.json diff --git a/change/react-native-windows-2019-12-20-14-28-11-master.json b/change/react-native-windows-2019-12-20-14-28-11-master.json new file mode 100644 index 00000000000..3bbf0606731 --- /dev/null +++ b/change/react-native-windows-2019-12-20-14-28-11-master.json @@ -0,0 +1,8 @@ +{ + "type": "none", + "comment": "supports SDK installed in other folder", + "packageName": "react-native-windows", + "email": "licanhua@live.com", + "commit": "9499a1d3b2f07a984e1dea233623cb06d8a47e6f", + "date": "2019-12-20T22:28:11.758Z" +} \ No newline at end of file