From d441cd544b9edb9fc8dbe1560ef009a46453556c Mon Sep 17 00:00:00 2001 From: jhaker Date: Wed, 17 Apr 2019 11:47:23 -0500 Subject: [PATCH] added visual studio 2019 support --- README.md | 7 +++++++ msbuild.js | 54 ++++++++++++++++++++++++++++++++-------------------- package.json | 5 +++-- 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index a0f00db..2c94ce0 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/msbuild.js b/msbuild.js index 81aa629..0b6f628 100644 --- a/msbuild.js +++ b/msbuild.js @@ -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; @@ -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. @@ -396,4 +408,4 @@ module.exports = function(callback){ if(typeof callback == 'function') callback(); }); return msb; -}; +}; \ No newline at end of file diff --git a/package.json b/package.json index 7d77078..3b415bf 100644 --- a/package.json +++ b/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", @@ -15,6 +15,7 @@ "saveSpec": null, "fetchSpec": "latest" }, + "main": "msbuild.js", "_requiredBy": [ "#USER", "/" @@ -49,5 +50,5 @@ "type": "git", "url": "git+https://github.com/jhaker/nodejs-msbuild.git" }, - "version": "1.0.3" + "version": "1.1.0" }