How To Always Use Angular's Latest Version With Visual Studio 2017

Angular

This article explains how to use the latest version of Angular with Visual Studio 2017 everytime. And also, it shows the options for using different versions of Angular with each project.

We know that there are a lot of templates available in Visual Studio 2017 to create a new project with Angular and .NET Core. Obviously, these templates are great and very helpful. These templates deserve much appreciation.

However, for some developers, using a template/extension becomes a limitation or boundary and he/she stops thinking beyond this boundary, which is not useful for the developers.  So, in this article, I am going to show you that we should not wait for any template or extension in Visual Studio to use the latest version of Angular.

Let’s try to understand it step-by-step and explore the options available for creating Angular App with Visual Studio 2017.

Option 1: Create an Angular App with .NET Core API in Visual Studio 2017 with inbuilt template

Step 1 - Open Visual Studio 2017.

Step 2 - Go to File >> New >> Project… (Ctrl + Shift + N).

Step 3 - Select “ASP.NET Core Web Application”. in the “New Project” window and provide other details.

Step 4 - Click "OK" button to continue.

Step 5 - Select "Angular Template" and click the "OK" button.

Angular

More detailed information can be found here.

Have a look at the “package.json” file.

Angular

“package.json” file complete code

  1. {  
  2.   "name""WebApplication32",  
  3.   "private"true,  
  4.   "version""0.0.0",  
  5.   "scripts": {  
  6.     "test""karma start ClientApp/test/karma.conf.js"  
  7.   },  
  8.   "devDependencies": {  
  9.     "@angular/animations""4.2.5",  
  10.     "@angular/common""4.2.5",  
  11.     "@angular/compiler""4.2.5",  
  12.     "@angular/compiler-cli""4.2.5",  
  13.     "@angular/core""4.2.5",  
  14.     "@angular/forms""4.2.5",  
  15.     "@angular/http""4.2.5",  
  16.     "@angular/platform-browser""4.2.5",  
  17.     "@angular/platform-browser-dynamic""4.2.5",  
  18.     "@angular/platform-server""4.2.5",  
  19.     "@angular/router""4.2.5",  
  20.     "@ngtools/webpack""1.5.0",  
  21.     "@types/chai""4.0.1",  
  22.     "@types/jasmine""2.5.53",  
  23.     "@types/webpack-env""1.13.0",  
  24.     "angular-router-loader""^0.8.2",  
  25.     "angular2-template-loader""0.6.2",  
  26.     "aspnet-prerendering""^3.0.1",  
  27.     "aspnet-webpack""^2.0.1",  
  28.     "awesome-typescript-loader""3.2.1",  
  29.     "bootstrap""3.3.7",  
  30.     "chai""4.0.2",  
  31.     "css""2.2.1",  
  32.     "css-loader""0.28.4",  
  33.     "es6-shim""0.35.3",  
  34.     "event-source-polyfill""0.0.9",  
  35.     "expose-loader""0.7.3",  
  36.     "extract-text-webpack-plugin""2.1.2",  
  37.     "file-loader""0.11.2",  
  38.     "html-loader""0.4.5",  
  39.     "isomorphic-fetch""2.2.1",  
  40.     "jasmine-core""2.6.4",  
  41.     "jquery""3.2.1",  
  42.     "json-loader""0.5.4",  
  43.     "karma""1.7.0",  
  44.     "karma-chai""0.1.0",  
  45.     "karma-chrome-launcher""2.2.0",  
  46.     "karma-cli""1.0.1",  
  47.     "karma-jasmine""1.1.0",  
  48.     "karma-webpack""2.0.3",  
  49.     "preboot""4.5.2",  
  50.     "raw-loader""0.5.1",  
  51.     "reflect-metadata""0.1.10",  
  52.     "rxjs""5.4.2",  
  53.     "style-loader""0.18.2",  
  54.     "to-string-loader""1.1.5",  
  55.     "typescript""2.4.1",  
  56.     "url-loader""0.5.9",  
  57.     "webpack""2.5.1",  
  58.     "webpack-hot-middleware""2.18.2",  
  59.     "webpack-merge""4.1.0",  
  60.     "zone.js""0.8.12"  
  61.   }  

You can see that it is using Angular Version 4.2.5 which is apparently not the latest one. However, it has been considered as the most stable version and that's why provided with the default template.

Option 2 - Creating Angular 5 App with Visual Studio 2017

You may want to try some new features of Angular 5; then you can use a template like “Angular5TemplateCore” to create a new Angular 5 app with .NET Core API.

Angular

You can visit here for more details. Now, open the “package.json” file and have a look at the Angular version.

Angular

You can see in the “package.json” file that it is using the version of Angular as “^5.0.0”. 

package.json complete code

  1. {  
  2.   "name""Angular5TF4",  
  3.   "version""0.0.0",  
  4.   "license""MIT",  
  5.   "scripts": {  
  6.     "ng""ng",  
  7.     "start""ng serve",  
  8.     "build""ng build",  
  9.     "test""ng test",  
  10.     "lint""ng lint",  
  11.     "e2e""ng e2e"  
  12.   },  
  13.   "private"true,  
  14.   "dependencies": {  
  15.     "@angular/cli""1.5.0",  
  16.     "@angular/compiler-cli""^5.0.0",  
  17.     "@angular/language-service""^5.0.0",  
  18.     "@types/jasmine""~2.5.53",  
  19.     "@types/jasminewd2""~2.0.2",  
  20.     "@types/node""~6.0.60",  
  21.     "codelyzer""~3.2.0",  
  22.     "jasmine-core""~2.6.2",  
  23.     "jasmine-spec-reporter""~4.1.0",  
  24.     "karma""~1.7.0",  
  25.     "karma-chrome-launcher""~2.1.1",  
  26.     "karma-cli""~1.0.1",  
  27.     "karma-coverage-istanbul-reporter""^1.2.1",  
  28.     "karma-jasmine""~1.1.0",  
  29.     "karma-jasmine-html-reporter""^0.2.2",  
  30.     "protractor""~5.1.2",  
  31.     "ts-node""~3.2.0",  
  32.     "tslint""~5.7.0",  
  33.     "typescript""~2.4.2",  
  34.     "@angular/animations""^5.0.0",  
  35.     "@angular/common""^5.0.0",  
  36.     "@angular/compiler""^5.0.0",  
  37.     "@angular/core""^5.0.0",  
  38.     "@angular/forms""^5.0.0",  
  39.     "@angular/http""^5.0.0",  
  40.     "@angular/platform-browser""^5.0.0",  
  41.     "@angular/platform-browser-dynamic""^5.0.0",  
  42.     "@angular/platform-server""^5.0.0",  
  43.     "@angular/router""^5.0.0",  
  44.     "@ngtools/webpack""1.8.0",  
  45.     "@types/webpack-env""1.13.0",  
  46.     "angular2-template-loader""0.6.2",  
  47.     "aspnet-prerendering""^3.0.1",  
  48.     "aspnet-webpack""^2.0.1",  
  49.     "awesome-typescript-loader""3.2.1",  
  50.     "bootstrap""3.3.7",  
  51.     "css""2.2.1",  
  52.     "css-loader""0.28.4",  
  53.     "es6-shim""0.35.3",  
  54.     "event-source-polyfill""0.0.9",  
  55.     "expose-loader""0.7.3",  
  56.     "extract-text-webpack-plugin""2.1.2",  
  57.     "file-loader""0.11.2",  
  58.     "html-loader""0.4.5",  
  59.     "isomorphic-fetch""2.2.1",  
  60.     "jquery""3.2.1",  
  61.     "json-loader""0.5.4",  
  62.     "preboot""4.5.2",  
  63.     "raw-loader""0.5.1",  
  64.     "reflect-metadata""0.1.10",  
  65.     "rxjs""5.4.2",  
  66.     "style-loader""0.18.2",  
  67.     "to-string-loader""1.1.5",  
  68.     "url-loader""0.5.9",  
  69.     "webpack""2.5.1",  
  70.     "webpack-hot-middleware""2.18.2",  
  71.     "webpack-merge""4.1.0",  
  72.     "zone.js""0.8.12"  
  73.   },  
  74.   "devDependencies": {  
  75.     "@angular/cli""1.5.0",  
  76.     "@angular/compiler-cli""^5.0.0",  
  77.     "@angular/language-service""^5.0.0",  
  78.     "@types/jasmine""~2.5.53",  
  79.     "@types/jasminewd2""~2.0.2",  
  80.     "@types/node""~6.0.60",  
  81.     "codelyzer""~3.2.0",  
  82.     "jasmine-core""~2.6.2",  
  83.     "jasmine-spec-reporter""~4.1.0",  
  84.     "karma""~1.7.0",  
  85.     "karma-chrome-launcher""~2.1.1",  
  86.     "karma-cli""~1.0.1",  
  87.     "karma-coverage-istanbul-reporter""^1.2.1",  
  88.     "karma-jasmine""~1.1.0",  
  89.     "karma-jasmine-html-reporter""^0.2.2",  
  90.     "protractor""~5.1.2",  
  91.     "ts-node""~3.2.0",  
  92.     "tslint""~5.7.0",  
  93.     "typescript""~2.4.2",  
  94.     "@types/chai""4.0.1",  
  95.     "chai""4.0.2",  
  96.     "karma-chai""0.1.0",  
  97.     "karma-webpack""2.0.3"  
  98.   }  
  99. }  

Option 3 - Always Use Angular Latest Version with Visual Studio 2017

As shown in “option 2”, we can create an Angular 5 app with Visual Studio 2017 very easily, but the latest version of Angular has been announced as “6.0.0-beta.2”.  The version mentioned is available while writing this article. You may get an upper version of Angular while using it.

Let’s create a new Angular app which will use the Angular Version “6.0.0-beta.2”, i.e., the latest version.

Follow the same steps as of “Option 1: Create an Angular App with .NET Core API in Visual Studio 2017 with inbuilt template” to create a new Angular App.

Open “package.json” file.

Start updating each package version in “package.json” file as shown in the below screenshot. Visual Studio will automatically suggest you that what is the latest version of a particular package, so you do not need to search anywhere or ask from someone. You can do all these changes by yourself and trust me it is straightforward. Following is a screenshot for the suggestion provided in Visual Studio.

Angular

Replace the earlier version “4.2.5” with "^6.0.0-beta.2". and upgrade other packages as well.

Once version upgrade is done then re-run the application. Following is a screenshot from the comparison window of the changes made to use the latest version of angular packages.

Angular

You may have noticed that I am using "^6.0.0-beta.2" instead of "6.0.0-beta.2" because we do not know that what should be the exact version for a specific package which is compatible with another package. However, if you wish you can use the exact version match.

package.json Complete code after update

  1. {  
  2.   "name""WebApplication35",  
  3.   "private"true,  
  4.   "version""0.0.0",  
  5.   "scripts": {  
  6.     "test""karma start ClientApp/test/karma.conf.js"  
  7.   },  
  8.   "devDependencies": {  
  9.     "@angular/animations""^6.0.0-beta.2",  
  10.     "@angular/common""^6.0.0-beta.2",  
  11.     "@angular/compiler""^6.0.0-beta.2",  
  12.     "@angular/compiler-cli""^6.0.0-beta.2",  
  13.     "@angular/core""^6.0.0-beta.2",  
  14.     "@angular/forms""^6.0.0-beta.2",  
  15.     "@angular/http""^6.0.0-beta.2",  
  16.     "@angular/platform-browser""^6.0.0-beta.2",  
  17.     "@angular/platform-browser-dynamic""^6.0.0-beta.2",  
  18.     "@angular/platform-server""^6.0.0-beta.2",  
  19.     "@angular/router""^6.0.0-beta.2",  
  20.     "@ngtools/webpack""^1.10.0-beta.3",  
  21.     "@types/chai""^4.1.2",  
  22.     "@types/jasmine""^2.8.6",  
  23.     "@types/webpack-env""^1.13.5",  
  24.     "angular2-router-loader""^0.3.5",  
  25.     "angular2-template-loader""^0.6.2",  
  26.     "aspnet-prerendering""^3.0.1",  
  27.     "aspnet-webpack""^2.0.3",  
  28.     "awesome-typescript-loader""^3.4.1",  
  29.     "bootstrap""^4.0.0",  
  30.     "chai""^4.1.2",  
  31.     "css""^2.2.1",  
  32.     "css-loader""^0.28.9",  
  33.     "es6-shim""^0.35.3",  
  34.     "event-source-polyfill""^0.0.12",  
  35.     "expose-loader""^0.7.4",  
  36.     "extract-text-webpack-plugin""^3.0.2",  
  37.     "file-loader""^1.1.6",  
  38.     "html-loader""^0.5.5",  
  39.     "isomorphic-fetch""^2.2.1",  
  40.     "jasmine-core""^2.9.1",  
  41.     "jquery""^3.3.1",  
  42.     "json-loader""^0.5.7",  
  43.     "karma""^2.0.0",  
  44.     "karma-chai""^0.1.0",  
  45.     "karma-chrome-launcher""^2.2.0",  
  46.     "karma-cli""^1.0.1",  
  47.     "karma-jasmine""^1.1.1",  
  48.     "karma-webpack""^2.0.9",  
  49.     "preboot""^6.0.0-beta.1",  
  50.     "raw-loader""^0.5.1",  
  51.     "reflect-metadata""^0.1.12",  
  52.     "rxjs""^5.5.6",  
  53.     "style-loader""^0.20.1",  
  54.     "to-string-loader""^1.1.5",  
  55.     "typescript""^2.7.1",  
  56.     "url-loader""^0.6.2",  
  57.     "webpack""^3.10.0",  
  58.     "webpack-hot-middleware""^2.21.0",  
  59.     "webpack-merge""^4.1.1",  
  60.     "zone.js""^0.8.20"  
  61.   }  
  62. }  

Actually in “package.json” file we can use provide a package version in 3 ways

  1. Exact Match
  2. Match the Most Recent Major Version (1.x.x)
  3. Match the most recent minor version (1.2.x)

Versioning of a software

Angular

Now, build and re-run the application. Following is the screenshot of the running application after the update which is using Angular Latest version i.e. “6.0.0-beta.2”.

Angular

Summary

In this article, we learned about the following things

  1. How to always use the latest version of Angular with Visual Studio 2017.
  2. Use default template and another online template to create Angular App.
  3. Use a different version of the Angular package with the different applications as per your requirement.

I have also attached the source code of complete project with latest updated version. You can go through my other Angular articles as well. Given below are the links for the same.

X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now