Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions change/react-native-windows-2019-12-20-14-28-11-master.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "none",
"comment": "supports SDK installed in other folder",
"packageName": "react-native-windows",
"email": "[email protected]",
"commit": "9499a1d3b2f07a984e1dea233623cb06d8a47e6f",
"date": "2019-12-20T22:28:11.758Z"
}
33 changes: 32 additions & 1 deletion vnext/local-cli/runWindows/utils/msbuildtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand Down Expand Up @@ -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 = [];

Expand All @@ -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;
Expand Down