Skip to content

Commit

Permalink
Allow UAP SDK to be in other folder other than ProgramFiles (#3815)
Browse files Browse the repository at this point in the history
* check UAP in SDK10 installation folder
  • Loading branch information
licanhua authored Dec 30, 2019
1 parent 609bbf3 commit f6ab28d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
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": "licanhua@live.com",
"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

0 comments on commit f6ab28d

Please sign in to comment.