Skip to content

Build Instructions

Paul van Brenk edited this page Dec 12, 2017 · 38 revisions

🎵Note: This documentation is outdated at this point, especially when using the Node tools in Visual Studio 2017. We're working on update docs, and will redirect you to those when they're ready.

Building NTVS on your PC allows you to pick up all the latest features and bug fixes, and also contribute back to the project. This page walks through the process of checking out and building NTVS on your local computer.

Once you have a good build, check out how to run our tests to get started with development.

Getting the Code

To checkout the latest code, just clone the Git repository:

git clone https://github.com/Microsoft/nodejstools.git
cd nodejstools

If you do not want to use Git, you can download the latest commit as a ZIP file.

If you plan to contribute back to NTVS, please fork the repo on Github and clone your fork instead:

git clone https://github.com/YOUR_USER_NAME/nodejstools.git
cd nodejstools

Selecting a Branch

There are two primary development branches:

  • master: new development (targeting VS2015 and VS vNext)
  • v1.1.x: patch release branch for v1.1 (targeting VS2012, VS2013, and VS2015)
  • v1.2.x: patch release branch for v1.2 (targeting VS2012, VS2013, and VS2015)

Once you've cloned the repository, you can check out the appropriate branch by using git checkout <branch-name>. For instance, if you wanted to check out the v1.2.x branch, you'd use git checkout v1.2.x.

Getting Ready to Build

1. Install Visual Studio

Download and install Microsoft Visual Studio Community. You'll need VS 2015 to build NTVS for VS 2015. Instructions in this document describe how to build using VS 2015 - building with older versions is similar.

You'll also need to install the Visual Studio Extensibility Tools (Features / Common Tools / Visual Studio Extensibility Tools) and Web Tools Features / Windows and Web Development / Web Tools components.

image

2. Run EnvironmentSetup.ps1

To execute environment setup, run

# from elevated cmd.exe
powershell -ExecutionPolicy RemoteSigned .\EnvironmentSetup.ps1

Alternatively, you can follow the manual environment setup steps below.

💡 If you already have NTVS installed for all users then you will get an error while compiling. The solution is to uninstall NTVS, or to reinstall it for the current user only. To install for the current user, install from the command line using msiexec /i NodejsToolsInstaller.msi ALLUSERS=""

Manual Environment Setup Steps

  1. Disable strong name verification for the Node.js Tools binaries

This can be done by merging the Nodejs\Prerequisites\EnableSkipVerification.reg file (or Nodejs\Prerequisites\EnableSkipVerificationX86.reg, depending on your own system). This will install registry keys which disable strong name verification for the assemblies built by NTVS. If you also want to use the installer you may need to stop and restart the Windows Installer service (from an elevated command prompt, type net stop "Windows Installer" and then net start "Windows Installer").

  1. Copy Microsoft.NodejsTools.targets from Nodejs\Product\Nodejs to "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\\{VS VERSION}\Node.js Tools\".

If this folder does not exist on your computer, which normally means you have never installed NTVS in this computer before, you can go ahead to create it.

  1. Optional: Install automated test tools for controlling Visual Studio.

These can be installed by running Common\Tests\Prerequisites\VSTestHost.msi for each version of Visual Studio. Additionally, be sure to update Visual Studio's test settings to point to Build\default.{VS VERSION}Exp.testsettings

Building with Visual Studio

NodejsTools.sln can be opened and built in Visual Studio using the Build Solution command. To debug, ensure that NodejsTools is selected as the startup project and use F5 to run NTVS inside of the VS Experimental hive. If an error appears rather than a new instance of VS, ensure the Project|Debug settings are correct.

🎵Note: Building in Visual Studio may produce a number of warnings related to potentially incompatible assemblies and missing references. As long as all projects build successfully, these warnings are benign and can be ignored.

Building with MSBuild

NTVS can be built from the Visual Studio Command Prompt::

$ cd NodeJs
$ msbuild NodejsTools.sln /p:VsTarget=14.0 /p:VisualStudioVersion=14.0
  • VisualStudioVersion - Version of visual studio on your local computer that you are using to build (13.0, 14.0, 15.0).
  • VsTarget - Version of visual studio that you are building the extension for (13.0, 14.0, 15.0).

This creates a debug build of NTVS and installs it into an VS Experimental hive, but does not create an installer or affect your main VS installation.

❗️Important: Building should complete with zero warnings or errors.

❗️Important: If you have any errors make sure that you use msbuild from C:\Program Files (x86)\MSBuild\14.0\bin. To ensure that you could run $env:Path="C:\Program Files (x86)\MSBuild\14.0\bin;"+$env:Path or SET PATH=C:\Program Files (x86)\MSBuild\14.0\Bin\;%PATH% from your shell.

Release Build

To create a release build, pass the /p:Configuration=Release flag to msbuild:

$ msbuild NodejsTools.sln /p:Configuration=Release /p:VsTarget=14.0 /p:VisualStudioVersion=14.0

As above, this does not create an .msi file, but it will install NTVS into the VS Experimental hive.

Running the Built Code

The VS Experimental hive can be started from the Start menu or by running

$ devenv /rootSuffix Exp

from the Visual Studio Command Prompt.

Building the Installer

The simplest way to build the installer is to run the release script Nodejs\Setup\BuildRelease.ps1 with PowerShell 3. This script updates the version to the current date, builds all flavors (Release, Debug) for each supported version of Visual Studio installed (currently VS 2015 and VS 2013), and archives the source code, binaries, symbols, and installers into an output directory.

powershell -ExecutionPolicy RemoteSigned .\BuildRelease.ps1 D:\NTVS_Out -skiptests

The output directory will contain VS 201x\Debug and VS 201x\Release folders (for each installed VS version) and a Sources folder. The Debug and Release directories will contain the installers, and the top level will contain all the release installers. This is the same script which we use to builds releases of NTVS, so you'll get an installer which works just like the released versions. However, unless you sign the binaries with your own code signing certificate, the installer will only work if the EnableSkipVerification.reg (or EnableSkipVerificationX86.reg) file has been merged into the registry on the destination computer.

The script provides many more options. Type powershell -ExecutionPolicy RemoteSigned Get-Help .\BuildRelease.ps1 for more information and `powershell -ExecutionPolicy RemoteSigned Get-Help .\BuildRelease.ps1 -examples for some examples.