Skip to content

Commit

Permalink
added visual studio 2019 support
Browse files Browse the repository at this point in the history
  • Loading branch information
jhaker committed Apr 17, 2019
1 parent 4935a09 commit d441cd5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 23 deletions.
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -2,6 +2,13 @@

Clean. Build. Package. Publish.

``` js
var _msbuild = require('..').__msbuild;
var msbuild = new _msbuild(function(){});
msbuild.sourcePath = 'c:/your_app.sln';
msbuild.config('version','16.0')
msbuild.build();
``` js
``` js
Expand Down
54 changes: 33 additions & 21 deletions msbuild.js
Expand Up @@ -111,7 +111,8 @@ msbuild.prototype.toolsVersion = {
'4.5': '4.0.30319',
'12.0': '12.0',
'14.0':'14.0',
'15.0':'15.0'
'15.0':'15.0',
'16.0':'16.0'
};

msbuild.prototype.__proto__ = events.EventEmitter.prototype;
Expand All @@ -124,36 +125,47 @@ msbuild.prototype.getMSBuildPath = function(os,processor,version){
if(os === 'linux' || os === 'darwin') return "xbuild";

var frameworkDirectories,programFilesDir,msbuildDir,exeDir;
var vs2017Type = {
Pro: 'Professional',
var vsEditions = {
Preview : 'Preview',
Professional: 'Professional',
Enterprise: 'Enterprise',
Community: 'Community',
BuildTools: 'BuildTools'
};

programFilesDir = process.env['programfiles(x86)'] || process.env.PROGRAMFILES;

// For the msbuild 15.0 version, use the appropriate VS2017 directories
if (version === "15.0") {

function getvsInstallDir(possibleVSInstallDir){
// If VSINSTALLDIR env. var cannot be found, see what could be the directory by searching the usual suspects
// (while giving higher priority to the VS2017 IDE installs over the Build Tools only install)
if (process.env.vsInstallDir === undefined) {
var possibleVSInstallDir = programFilesDir + '\\' + 'Microsoft Visual Studio\\2017\\';
if (fs.existsSync(possibleVSInstallDir + vs2017Type.Pro))
msbuildDir = possibleVSInstallDir + vs2017Type.Pro + '\\';
else if (fs.existsSync(possibleVSInstallDir + vs2017Type.Enterprise + '\\'))
msbuildDir = possibleVSInstallDir + vs2017Type.Enterprise + '\\';
else if (fs.existsSync(possibleVSInstallDir + vs2017Type.Community + '\\'))
msbuildDir = possibleVSInstallDir + vs2017Type.Community + '\\';
else if (fs.existsSync(possibleVSInstallDir + vs2017Type.BuildTools + '\\'))
msbuildDir = possibleVSInstallDir + vs2017Type.BuildTools + '\\';
if (fs.existsSync(possibleVSInstallDir + vsEditions.Professional))
return possibleVSInstallDir + vsEditions.Professional + '\\';
else if (fs.existsSync(possibleVSInstallDir + vsEditions.Enterprise + '\\'))
return possibleVSInstallDir + vsEditions.Enterprise + '\\';
else if (fs.existsSync(possibleVSInstallDir + vsEditions.Community + '\\'))
return possibleVSInstallDir + vsEditions.Community + '\\';
else if (fs.existsSync(possibleVSInstallDir + vsEditions.Preview))
return possibleVSInstallDir + vsEditions.Preview + '\\';
else if (fs.existsSync(possibleVSInstallDir + vsEditions.BuildTools + '\\'))
return possibleVSInstallDir + vsEditions.BuildTools + '\\';
}
else
msbuildDir = process.env.vsInstallDir;

exeDir = msbuildDir + 'MSBuild\\15.0\\bin\\msbuild.exe';

return process.env.vsInstallDir;
}

// For the msbuild 15.0 version, use the appropriate VS2017 directories
if (version === "15.0") {
msbuildDir = getvsInstallDir(programFilesDir + '\\' + 'Microsoft Visual Studio\\2017\\');
exeDir = msbuildDir + 'MSBuild\\'+version+'\\bin\\msbuild.exe';
}

// For the msbuild 16.0 version, use the appropriate VS2019 directories
if (version === "16.0") {
msbuildDir = getvsInstallDir(programFilesDir + '\\' + 'Microsoft Visual Studio\\2019\\');
exeDir = msbuildDir + 'MSBuild\\'+version+'\\bin\\msbuild.exe';
if (!(fs.existsSync(exeDir)))
exeDir = msbuildDir + 'MSBuild\\Current\\bin\\msbuild.exe';
}

// If the msbuild.exe file exists, we are done.
Expand Down Expand Up @@ -396,4 +408,4 @@ module.exports = function(callback){
if(typeof callback == 'function') callback();
});
return msb;
};
};
5 changes: 3 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"_from": "msbuild",
"_id": "msbuild@1.0.3",
"_id": "msbuild@1.1.0",
"_inBundle": false,
"_integrity": "sha512-TabbjPSpIznu5cJo/fmkS5vtO/vY5kgRgFZBygTbNs19TLKo9091SwdluugTDH5Hp6wfgrFtojtIvKsyh8//xg==",
"_location": "/msbuild",
Expand All @@ -15,6 +15,7 @@
"saveSpec": null,
"fetchSpec": "latest"
},
"main": "msbuild.js",
"_requiredBy": [
"#USER",
"/"
Expand Down Expand Up @@ -49,5 +50,5 @@
"type": "git",
"url": "git+https://github.com/jhaker/nodejs-msbuild.git"
},
"version": "1.0.3"
"version": "1.1.0"
}

0 comments on commit d441cd5

Please sign in to comment.