
Run various Node tools as a MSBuild task.
MSBuild.NodeTools is available as a NuGet Package with the same name. This package contains all the available tools.
Install-Package MSBuild.NodeTools
It is also possible to install each tool seperately.
Install-Package MSBuild.Npm
Install-Package MSBuild.Bower
Install-Package MSBuild.Gulp
Install-Package MSBuild.Grunt
NuGet will automatically add the MSBuild targets to the .csproj file.
Download the files in the build/ folder and put them in your project folder.
Then open the .csproj file in an editor and do the following changes.
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Put this at the top of the Project node -->
<Import Project="..\path\to\MSBuild.Node.props" Condition="Exists('..\path\to\MSBuild.Node.props')" />
<!-- Import *.props file for the tool(s) that you need -->
<!--
other stuff goes here...
-->
<!-- Put this at the bottom of the Project node -->
<Import Project="..\path\to\MSBuild.Node.targets" Condition="Exists('..\path\to\MSBuild.Node.targets')" />
<!-- Import *.targets file for the tool(s) that you need -->
</Project>Note that the MSBuild.Node.props and MSBuild.Node.targets is required by
all the tools and must always be included.
There are various configuration properties you can overwrite in the .csproj file
after importing MSBuild.*.props but before importing MSBuild.*.targets.
MSBuild.Node tries to find the global NodeJS by reading the NODEJS environment
variable first and then executing where node when it is unset.
It also tries to locate the global npm folder. The global paths are stored in
the following properties which should not be overriden.
GlobalNodePath: Defaults to$(NODEJS)orwhere nodeGlobalNodeModulePath: Defaults to$(HOMEDRIVE)$(HOMEPATH)\AppData\Roaming\npm
If no global NodeJS installation is available or if a local installation should be used instead, set these properties instead:
LocalNodePath: Path to the local NodeJS installation.LocalNodeModulePath: Path to the local npm modules folder.
NpmFile: Path to the npm file. Defaults to$(MSBuildProjectDirectory)\package.json.NpmCommand: Npm command that should be run. Defaults toinstall --loglevel error.
BowerFile: Path to the bower file. Defaults to$(MSBuildProjectDirectory)\bower.json.BowerCommand: Bower command that should be run. Defaults toinstall.
If no global Git installation is available or if a local installation should be used instead, set these properties instead:
LocalGitPath: Path to the local git installation.
GulpFile: Path to gulpfile. Defaults to$(MSBuildProjectDirectory)\gulpfile.[js|coffee].GulpWorkingDirectory: Directory in which context the gulp task gets executed. Defaults to$(MSBuildProjectDirectory).GulpTask: [deprecated] SeeGulpBuildTask.GulpBuildTask: Gulp task that gets executed on build. Defaults tobuild-$(Configuration).GulpCleanTask: Gulp task that gets executed on clean. Defaults to unset.
GruntFile: Path to gruntfile. Defaults to$(MSBuildProjectDirectory)\gruntfile.[js|coffee].GruntWorkingDirectory: Directory in which context the grunt task gets executed. Defaults to$(MSBuildProjectDirectory).GruntTask: [deprecated] SeeGruntBuildTask.GruntBuildTask: Grunt task that gets executed on build. Defaults tobuild-$(Configuration).GruntCleanTask: Grunt task that gets executed on clean. Defaults to unset.
- v0.5.1
- Add
ConsoleToMsBuildflag to gulp and grunt task (this time for real).
- Add
- v0.5.0
- Bugfix for npm and bower working directory.
- Support for local git when using bower.
⚠️ Remove quotes aroundGruntBuildTaskandGruntCleanTask. In case that breaks some, please open an issue.- Add
ConsoleToMsBuildflag to gulp and grunt task.
- v0.4.2 Performance Improvements
- Run npm targets before
BeforeBuild/BeforeCleaninstead ofPrepareForBuild. - Run bower targets before
BeforeBuildinstead ofPrepareForBuild.
- Run npm targets before
- v0.4.1 Bugfixes
- v0.4.0 MSBuild.Grunt and MSBuild.Gulp support
cleantarget.