Steps:
Go to wwwroot, and create a normal html page called Index.html:
Configure Startup.cs to accept static files (this will require to add "Microsoft.AspNetCore.StaticFiles": "1.0.0" library in the “project.json” file):
Add NPN File:
Right click the WebUi project and add NPN Configuration File (package.json):
Verify the last versions of the packages:
Note: If visual studio does not detect the versions of the packages (Check all packages, because some of them does show the version, and some others don't), it might be because the Node version coming in visual studio is not working correctly, so it will probably require to install node js externally and then link that installation with visual studio.
i. Download and install node js: https://nodejs.org/es/download/
ii. Link the installation with visual studio: https://ryanhayes.net/synchronize-node-js-install-version-with-visual-studio-2015/: iii. (Optional) after saving the package.json it will install the dependencies in the project, if not, run "npm install" using a command prompt from the same location as the package.json file.
Note: Recommended to install "Open Command Line", an extension that can be added to Visual Studio:
Add typescript:
Create a TsScript folder inside the WebUi project, just for organization (The TypeScripts won't go to the browser, they will be transpiled into a normal JS file, and this JS file will be the one going to the wwwroot foder using gulp, this will be explained later):
Inside that folder add "TypeScript JSON Configuration File" (tsconfig.json): And add the next code:
In the WebUi Project’s root, add a new file called typings.json: And add the next code:
In the Web Project root open a command line and execute "typings install", this will create a typings folder (This requires “Open Command Line” explained as an optional step in the Note inside Step 4, numeral iii).
Add gulp to move files:
Add Angular 2 bootstrapping files inside the “tsScripts” folder:
Inside the scripts folder (but outside app), add the systemjs.config.js: And add the next code:
Execute Gulp Task to generate the scripts in wwwroot.
Now run and enjoy.
Notes:
References:
Deborah Kurata's "Angular 2: Getting Started" course in Pluralsight:
https://www.pluralsight.com/courses/angular-2-getting-started-update
Angular 2 Official Documentation:
Articles by Mithun Pattankar:
http://www.mithunvp.com/angular-2-in-asp-net-5-typescript-visual-studio-2015/
http://www.mithunvp.com/using-angular-2-asp-net-mvc-5-visual-studio/