Skip to content

Commit a4fa07b

Browse files
purplecodebnoordhuis
authored andcommitted
More verbose error on locating msbuild.exe failure.
PR-URL: #930 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 4ee3132 commit a4fa07b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: lib/build.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,19 @@ function build (gyp, argv, callback) {
125125

126126
function findMsbuild () {
127127
log.verbose('could not find "msbuild.exe" in PATH - finding location in registry')
128-
var notfoundErr = new Error('Can\'t find "msbuild.exe". Do you have Microsoft Visual Studio C++ 2008+ installed?')
128+
var notfoundErr = 'Can\'t find "msbuild.exe". Do you have Microsoft Visual Studio C++ 2008+ installed?'
129129
var cmd = 'reg query "HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions" /s'
130130
if (process.arch !== 'ia32')
131131
cmd += ' /reg:32'
132132
exec(cmd, function (err, stdout, stderr) {
133+
if (err) {
134+
return callback(new Error(err.message + '\n' + notfoundErr))
135+
}
133136
var reVers = /ToolsVersions\\([^\\]+)$/i
134137
, rePath = /\r\n[ \t]+MSBuildToolsPath[ \t]+REG_SZ[ \t]+([^\r]+)/i
135138
, msbuilds = []
136139
, r
137140
, msbuildPath
138-
if (err) {
139-
return callback(notfoundErr)
140-
}
141141
stdout.split('\r\n\r\n').forEach(function(l) {
142142
if (!l) return
143143
l = l.trim()
@@ -157,15 +157,15 @@ function build (gyp, argv, callback) {
157157
return (x.version < y.version ? -1 : 1)
158158
})
159159
;(function verifyMsbuild () {
160-
if (!msbuilds.length) return callback(notfoundErr)
160+
if (!msbuilds.length) return callback(new Error(notfoundErr))
161161
msbuildPath = path.resolve(msbuilds.pop().path, 'msbuild.exe')
162162
fs.stat(msbuildPath, function (err, stat) {
163163
if (err) {
164164
if (err.code == 'ENOENT') {
165165
if (msbuilds.length) {
166166
return verifyMsbuild()
167167
} else {
168-
callback(notfoundErr)
168+
callback(new Error(notfoundErr))
169169
}
170170
} else {
171171
callback(err)

0 commit comments

Comments
 (0)