@@ -119,22 +119,33 @@ function build (gyp, argv, callback) {
119
119
function findMsbuild ( ) {
120
120
log . verbose ( 'could not find "msbuild.exe" in PATH - finding location in registry' )
121
121
var notfoundErr = new Error ( 'Can\'t find "msbuild.exe". Do you have Microsoft Visual Studio C++ 2008+ installed?' )
122
- exec ( 'reg query "HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions" /s' , function ( err , stdout , stderr ) {
123
- var reVers = / S o f t w a r e \\ M i c r o s o f t \\ M S B u i l d \\ T o o l s V e r s i o n s \\ ( [ ^ \r ] + ) \r \n \s + M S B u i l d T o o l s P a t h \s + R E G _ S Z \s + ( [ ^ \r ] + ) / gi
122
+ var cmd = 'reg query "HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions" /s'
123
+ if ( process . arch !== 'ia32' )
124
+ cmd += ' /reg:32'
125
+ exec ( cmd , function ( err , stdout , stderr ) {
126
+ var reVers = / T o o l s V e r s i o n s \\ ( [ ^ \\ ] + ) $ / i
127
+ , rePath = / \r \n [ \t ] + M S B u i l d T o o l s P a t h [ \t ] + R E G _ S Z [ \t ] + ( [ ^ \r ] + ) / i
124
128
, msbuilds = [ ]
125
129
, r
126
130
, msbuildPath
127
131
if ( err ) {
128
132
return callback ( notfoundErr )
129
133
}
130
- while ( r = reVers . exec ( stdout ) ) {
131
- if ( parseFloat ( r [ 1 ] , 10 ) >= 3.5 ) {
132
- msbuilds . push ( {
133
- version : parseFloat ( r [ 1 ] , 10 ) ,
134
- path : r [ 2 ]
135
- } )
134
+ stdout . split ( '\r\n\r\n' ) . forEach ( function ( l ) {
135
+ if ( ! l ) return
136
+ l = l . trim ( )
137
+ if ( r = reVers . exec ( l . substring ( 0 , l . indexOf ( '\r\n' ) ) ) ) {
138
+ var ver = parseFloat ( r [ 1 ] , 10 )
139
+ if ( ver >= 3.5 ) {
140
+ if ( r = rePath . exec ( l ) ) {
141
+ msbuilds . push ( {
142
+ version : ver ,
143
+ path : r [ 1 ]
144
+ } )
145
+ }
146
+ }
136
147
}
137
- }
148
+ } )
138
149
msbuilds . sort ( function ( x , y ) {
139
150
return ( x . version < y . version ? - 1 : 1 )
140
151
} )
0 commit comments