windows-autoconf
Advanced tools
Comparing version 1.8.1 to 1.9.0
43
index.js
@@ -120,3 +120,3 @@ 'use strict' | ||
const reg = lazy.bindings.execSync(`"${vsSetup.CmdPath}" /nologo & set`).toString().trim().split(/\r?\n/g) | ||
const reg = lazy.bindings.execSync(`"${vsSetup.CmdPath}" -no_logo & set`).toString().trim().split(/\r?\n/g) | ||
vsSetup.SDKFull = reg.find(l => l.includes('WindowsSDKVersion')).split('=').pop().replace('\\', '') | ||
@@ -143,2 +143,13 @@ vsSetup.Version = reg.find(l => l.includes('VCToolsInstallDir')).replace(/.*?\\([\d.]{5,})\\.*/, '$1') | ||
function tryRegistryMSBuild () { | ||
try { | ||
const msbSetups = execAndParse(module.exports.try_registry_msbuild_path) | ||
const vers = msbSetups.map(s => s['ver']).sort().reverse() | ||
const msbSetup = msbSetups.find(s => s['ver'] === vers[0]) | ||
return msbSetup | ||
} catch (e) { | ||
lazy.bindings.log('Couldn\'t find any SDK in registry') | ||
} | ||
} | ||
function getVS2017Setup () { | ||
@@ -153,7 +164,17 @@ if ('cache2017' in getVS2017Setup) return getVS2017Setup.cache2017 | ||
function locateMsbuild () { | ||
const msbSetup = locateMSBuild2017() || tryRegistryMSBuild() | ||
if (!msbSetup) { | ||
lazy.bindings.log('Can\'t find "msbuild.exe"') | ||
return | ||
} | ||
return msbSetup.MSBuildPath | ||
} | ||
function locateMSBuild2017 () { | ||
const vsSetup = getVS2017Setup() | ||
const msbuildLocation = lazy.bindings.path.join( | ||
vsSetup.InstallationPath, 'MSBuild', '15.0', 'Bin', 'MSBuild.exe' | ||
) | ||
return msbuildLocation | ||
if (!vsSetup) return | ||
const ver = '15.0' | ||
const MSBuildToolsPath = lazy.bindings.path.join(vsSetup.InstallationPath, 'MSBuild', ver, 'Bin') | ||
const MSBuildPath = lazy.bindings.path.join(MSBuildToolsPath, 'MSBuild.exe') | ||
return {ver, MSBuildToolsPath, MSBuildPath} | ||
} | ||
@@ -298,2 +319,3 @@ | ||
try_registry_sdk_path: `"${__dirname}\\tools\\try_registry_sdk.cmd"`, | ||
try_registry_msbuild_path: `"${__dirname}\\tools\\try_registry_msbuild.cmd"`, | ||
check_VS2017_COM_path: `"${__dirname}\\tools\\check_VS2017_COM.cmd"`, | ||
@@ -304,2 +326,3 @@ setBindings, | ||
locateMsbuild, | ||
locateMSBuild2017, | ||
getMSVSVersion: (version) => getMSVSSetup(version).version, | ||
@@ -309,3 +332,11 @@ getOSBits, | ||
resolveDevEnvironment, | ||
_forTesting: {tryVS2017Powershell, tryVS2017CSC, tryVS2017Registry, tryRegistrySDK, getWithFullCmd, execAndParse} | ||
_forTesting: { | ||
tryVS2017Powershell, | ||
tryVS2017CSC, | ||
tryVS2017Registry, | ||
tryRegistrySDK, | ||
tryRegistryMSBuild, | ||
getWithFullCmd, | ||
execAndParse | ||
} | ||
} |
{ | ||
"name": "windows-autoconf", | ||
"version": "1.8.1", | ||
"version": "1.9.0", | ||
"description": "Try to find MS build tools", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -177,2 +177,19 @@ /* eslint-disable no-path-concat */ | ||
it('Registry MSBuild', function () { | ||
this.timeout(10000) | ||
const msbSetup = getter._forTesting.tryRegistryMSBuild() | ||
if (!msbSetup) { | ||
console.log('registry method failed') | ||
return this.skip() | ||
} | ||
assert(msbSetup.ver) | ||
assert(msbSetup.MSBuildToolsPath) | ||
assert(fs.existsSync(msbSetup.MSBuildToolsPath)) | ||
assert(msbSetup.MSBuildPath) | ||
const parts = msbSetup.MSBuildPath.split('\\') | ||
assert(parts.length >= 4) | ||
assert(parts.pop() === 'MSBuild.exe') | ||
assert(fs.existsSync(msbSetup.MSBuildPath)) | ||
}) | ||
after(() => { | ||
@@ -201,2 +218,3 @@ const pathParts = weirdDir.split('\\') | ||
}) | ||
describe('2017 only', function () { | ||
@@ -241,8 +259,12 @@ before(function () { | ||
it('locateMsbuild', () => { | ||
const path = getter.locateMsbuild() | ||
const parts = path.split('\\') | ||
it('locateMSBuild2017', () => { | ||
const msbSetup = getter.locateMSBuild2017() | ||
assert.equal(msbSetup.ver, '15.0') | ||
assert(msbSetup.MSBuildToolsPath) | ||
assert(fs.existsSync(msbSetup.MSBuildToolsPath)) | ||
assert(msbSetup.MSBuildPath) | ||
const parts = msbSetup.MSBuildPath.split('\\') | ||
assert(parts.length >= 4) | ||
assert(path.match(/MSBuild\.exe$/i)) | ||
assert(fs.existsSync(path)) | ||
assert(parts.pop() === 'MSBuild.exe') | ||
assert(fs.existsSync(msbSetup.MSBuildPath)) | ||
}) | ||
@@ -291,2 +313,11 @@ }) | ||
}) | ||
it('locateMsbuild', () => { | ||
const msbPath = getter.locateMsbuild() | ||
const parts = msbPath.split('\\') | ||
assert(parts.length >= 4) | ||
assert(parts.pop() === 'MSBuild.exe') | ||
assert(fs.existsSync(msbPath)) | ||
}) | ||
}) | ||
@@ -293,0 +324,0 @@ |
Sorry, the diff of this file is not supported yet
41981
19
645