Creating a project

To create a new Node.js project you use the normal File->New Project command from Visual Studio. The Node.js project types are listed under the “JavaScript” language which will either be under “Installed Templates” or “Installed Templates\Other Languages” depending upon your settings.

 New Project Dialog

Built-in project types

Node.js Tools for Visual Studio includes two different project types. The first is a “Blank Node.js Application.” This application consists of a project with a simple server.js file which will server requests. You can use this project type to edit, run, debug, and profile your Node.js application.

The second project type is “Blank Windows Azure Node.js Application”. This includes the same hello world application as “Blank Node.js Application” but also includes additional functionality for deploying to Windows Azure. There is a web.config file which configures Node.js for running under IIS Node as well as deployment scripts for starting a Node.js application on a Windows Azure web role.


Adding existing folders 

Add Existing Folder

Whether you've just created a project or just did an npm install, frequently you'll need to add an existing folder into your project.  You can quickly do this with the "Add Existing Folder" command.  If the folder is on the same location on disk as it is in Solution Explorer the files will quickly be added to your project.  If they're at a different location they will be copied into your project folder.

You can also drag and drop folders from Window Explorer into Solution Explorer to add them.


Project Features 

Linked Files

Linked file

Linked files appear in solution explorer as normal files with a shortcut icon overlayed on top of them. Linked files can exist either at the top-level of the project or embedded within an arbitrary folder structure.

Linked files are specified in the .njsproj file using the normal <Compile Include> tag. They can be implicit linked files if they use a relative path outside of the directory structure or they can be explicit link files by specifying their path within solution explorer:

  <Compile Include="..\test2.js">

Linked files specified in a project file will be ignored under the following conditions:

  • When the linked file contains Link metadata and the path specified in the Include attribute lives within the project directory.
  • When the linked file duplicates a file which exists within the project hierarchy
  • When the linked file contains Link metadata and the Link path is a relative path outside of the solution explorer hierarchy.
  • The link path is rooted

Adding Existing Items as Links

To add an existing item as a link the user can use the Project->Add Existing Item menu (or the context menu), select a file, and choose “Add as Link” from the drop down on the Add button. This will create a link at the existing selected level in Solution Explorer. When creating a link to a file which lives within the project directory or a child directory the file will be added to the project in the correct location as a normal file instead of a link.

Creating New Linked Files

A user can create a linked file via the user interface by doing File->Save As for a file which exists somewhere within the project hierarchy. The old file node in the project will be removed and replaced by a linked file node (the link is created at the same location in the hierarchy as the previous node). The old file on disk will not be deleted.

Converting Linked Files to Normal Files

A linked file can be converted into a normal file by doing File->Save As and saving the file into a location within the project hierarchy. The node in the project hierarchy will be moved into the appropriate location in solution explorer

Moving Linked Files

When using the solution explorer UI to move a linked file the end result is that the link moves but the file on disk remains unaffected. If the file was open in the editor the file will remain open.

Deleting Linked Files

When using the solution explorer UI to delete a linked file the end result is that the link is removed from the project and the file remains on disk. The user is not prompted for the option to delete the file.

Renaming Linked Files

Renaming of linked files will not be allowed. Both renaming on the node as well as renaming via project properties will be disallowed. Attempting to rename a file via the automation API will raise an InvalidOperationException.

Duplicate Linked Files and Normal Files

If a project contains both a linked file and a normal file at the same level of the solution hierarchy the linked file will be renamed. When adding a new file or link to the project if an existing file or link exists at the same level in the hierarchy then the addition will not be allowed. Additionally if a link to a file already exists anywhere within the project a second link will not be permitted to be added. If the user modifies the project by hand to introduce duplicate links then only one link will be added when loading the project file.

Last edited Nov 13, 2013 at 9:10 PM by huguesv, version 8


No comments yet.