Skip to main content

How To Setup Angular 2 in Visual Studio 2017 MVC 5 / 6?

How To Building Angular 2 Apps using Visual Studio 2017 and MVC 6?

This post helps us to learn how to Setup and Create an Application that Uses Angular 2 for the client side and ASP.NET Core with single page application (SPA) for the server application.


Open Command Prompt and Follow the below mention Steps.

Note - In the below steps, Viainda is a user in my machine. So that your end, you will see you or your user in your machine.

Steps 1- C:\Users\Viainda>
Steps 2- C:\Users\Viainda>F:
Steps 3- F:\>
Steps 4- F:\>mkdir Ng2DemoApp
Steps 5- F:\>cd Ng2DemoApp
Steps 6- F:\Ng2DemoApp>node --version
v7.1.0

Steps 7- F:\Ng2DemoApp>dotnet new --install Microsoft.AspNetCore.SpaTemplates::*
Restoring packages for C:\Users\Viainda\.templateengine\dotnetcli\v1.0.3\scratch\restore.csproj...
  Installing System.Xml.XPath 4.0.1.
  Installing runtime.native.System.IO.Compression 4.1.0.
  Installing Microsoft.NETCore.DotNetHost 1.0.1.
  Installing Microsoft.NETCore.Targets 1.0.1.
  Installing System.Xml.XPath.XDocument 4.0.1.
  Installing System.Xml.XmlDocument 4.0.1.
  Installing System.Text.Encoding.CodePages 4.0.1.
  Installing Microsoft.NETCore.App 1.0.4.
  Installing System.Diagnostics.StackTrace 4.0.1.
  Installing Microsoft.AspNetCore.SpaTemplates 0.9.1.
  Installing System.Diagnostics.FileVersionInfo 4.0.0.
  Installing Microsoft.CodeAnalysis.Analyzers 1.1.0.
  Installing Libuv 1.9.1.
  Installing Microsoft.CodeAnalysis.CSharp 1.3.0.
  Installing System.Security.Cryptography.Csp 4.0.0.
  Installing System.Security.Cryptography.Cng 4.2.0.
  Installing System.Security.Principal 4.0.1.
  Installing System.Security.Claims 4.0.1.
  Installing runtime.native.System.Net.Security 4.0.1.
  Installing System.Security.Principal.Windows 4.0.0.
  Installing Microsoft.CodeAnalysis.VisualBasic 1.3.0.
  Installing Microsoft.CSharp 4.0.1.
  Installing Microsoft.NETCore.DotNetHostPolicy 1.0.3.
  Installing Microsoft.NETCore.Platforms 1.0.2.
  Installing Microsoft.NETCore.Runtime.CoreCLR 1.0.6.
  Installing Microsoft.VisualBasic 10.0.1.
  Installing NETStandard.Library 1.6.0.
  Installing System.Buffers 4.0.0.
  Installing System.Collections.Immutable 1.2.0.
  Installing System.ComponentModel 4.0.1.
  Installing System.ComponentModel.Annotations 4.1.0.
  Installing System.Diagnostics.DiagnosticSource 4.0.0.
  Installing System.Diagnostics.Process 4.1.0.
  Installing System.Dynamic.Runtime 4.0.11.
  Installing System.Globalization.Extensions 4.0.1.
  Installing System.IO.FileSystem.Watcher 4.0.0.
  Installing System.IO.MemoryMappedFiles 4.0.0.
  Installing System.IO.UnmanagedMemoryStream 4.0.1.
  Installing System.Linq.Expressions 4.1.1.
  Installing System.Linq.Parallel 4.0.1.
  Installing System.Linq.Queryable 4.0.1.
  Installing System.Net.Http 4.1.1.
  Installing System.Net.NameResolution 4.0.0.
  Installing System.Net.Requests 4.0.11.
  Installing System.Net.Security 4.0.0.
  Installing System.Net.WebHeaderCollection 4.0.1.
  Installing System.Numerics.Vectors 4.1.1.
  Installing System.Reflection.DispatchProxy 4.0.1.
  Installing System.Reflection.Metadata 1.3.0.
  Installing System.Reflection.TypeExtensions 4.1.0.
  Installing System.Resources.Reader 4.0.0.
  Installing System.Runtime.Loader 4.0.0.
  Installing System.Security.Cryptography.Algorithms 4.2.0.
  Installing System.Security.Cryptography.Encoding 4.0.0.
  Installing System.Security.Cryptography.Primitives 4.0.0.
  Installing System.Security.Cryptography.X509Certificates 4.1.0.
  Installing System.Threading.Tasks.Dataflow 4.6.0.
  Installing System.Threading.Tasks.Extensions 4.0.0.
  Installing System.Threading.Tasks.Parallel 4.0.1.
  Installing System.Threading.Thread 4.0.0.
  Installing System.Threading.ThreadPool 4.0.10.
  Installing Microsoft.CodeAnalysis.Common 1.3.0.
  Installing System.Collections 4.0.11.
  Installing System.Diagnostics.Debug 4.0.11.
  Installing System.Globalization 4.0.11.
  Installing System.Linq 4.1.0.
  Installing System.ObjectModel 4.0.12.
  Installing System.Reflection 4.1.0.
  Installing System.Reflection.Extensions 4.0.1.
  Installing System.Reflection.Primitives 4.0.1.
  Installing System.Security.Cryptography.OpenSsl 4.0.0.
  Installing System.Resources.ResourceManager 4.0.1.
  Installing System.Runtime 4.1.0.
  Installing System.Runtime.Extensions 4.1.0.
  Installing System.Runtime.InteropServices 4.1.0.
  Installing System.Threading 4.0.11.
  Installing Microsoft.NETCore.DotNetHostResolver 1.0.1.
  Installing Microsoft.NETCore.Jit 1.0.6.
  Installing Microsoft.NETCore.Windows.ApiSets 1.0.1.
  Installing Microsoft.Win32.Primitives 4.0.1.
  Installing System.AppContext 4.1.0.
  Installing System.Collections.Concurrent 4.0.12.
  Installing System.Console 4.0.0.
  Installing System.Diagnostics.Tools 4.0.1.
  Installing System.Diagnostics.Tracing 4.1.0.
  Installing System.Globalization.Calendars 4.0.1.
  Installing System.IO 4.1.0.
  Installing System.IO.Compression 4.1.0.
  Installing System.IO.Compression.ZipFile 4.0.1.
  Installing System.IO.FileSystem 4.0.1.
  Installing System.IO.FileSystem.Primitives 4.0.1.
  Installing System.Net.Primitives 4.0.11.
  Installing System.Net.Sockets 4.1.0.
  Installing System.Runtime.Handles 4.0.1.
  Installing System.Runtime.InteropServices.RuntimeInformation 4.0.0.
  Installing System.Runtime.Numerics 4.0.1.
  Installing System.Text.Encoding 4.0.11.
  Installing System.Text.Encoding.Extensions 4.0.11.
  Installing System.Text.RegularExpressions 4.1.0.
  Installing System.Threading.Tasks 4.0.11.
  Installing System.Threading.Timer 4.0.1.
  Installing System.Xml.ReaderWriter 4.0.11.
  Installing System.Xml.XDocument 4.0.11.
  Installing Microsoft.Win32.Registry 4.0.0.
  Installing runtime.native.System 4.0.0.
  Installing System.Reflection.Emit 4.0.1.
  Installing System.Reflection.Emit.ILGeneration 4.0.1.
  Installing runtime.native.System.Security.Cryptography 4.0.0.
  Installing System.Threading.Overlapped 4.0.1.
  Installing System.Reflection.Emit.Lightweight 4.0.1.
  Installing runtime.native.System.Net.Http 4.0.1.
  Generating MSBuild file C:\Users\Viainda\.templateengine\dotnetcli\v1.0.3\scratch\obj\restore.csproj.nuget.g.props.
  Generating MSBuild file C:\Users\Viainda\.templateengine\dotnetcli\v1.0.3\scratch\obj\restore.csproj.nuget.g.targets.
  Writing lock file to disk. Path: C:\Users\Viainda\.templateengine\dotnetcli\v1.0.3\scratch\obj\project.assets.json
  Restore completed in 47.8 sec for C:\Users\Viainda\.templateengine\dotnetcli\v1.0.3\scratch\restore.csproj.

  NuGet Config files used:
      C:\Users\Viainda\AppData\Roaming\NuGet\NuGet.Config
      C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config

  Feeds used:
      https://api.nuget.org/v3/index.json
      C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

  Installed:
      111 package(s) to C:\Users\Viainda\.templateengine\dotnetcli\v1.0.3\scratch\restore.csproj
Templates                                     Short Name      Language      Tags
------------------------------------------------------------------------------------------
Console Application                           console         [C#], F#      Common/Console
Class library                                 classlib        [C#], F#      Common/Library
Unit Test Project                             mstest          [C#], F#      Test/MSTest
xUnit Test Project                            xunit           [C#], F#      Test/xUnit
ASP.NET Core Empty                            web             [C#]          Web/Empty
ASP.NET Core Web App                          mvc             [C#], F#      Web/MVC
MVC ASP.NET Core with Angular                 angular         [C#]          Web/MVC/SPA
MVC ASP.NET Core with Aurelia                 aurelia         [C#]          Web/MVC/SPA
MVC ASP.NET Core with Knockout.js             knockout        [C#]          Web/MVC/SPA
MVC ASP.NET Core with React.js                react           [C#]          Web/MVC/SPA
MVC ASP.NET Core with React.js and Redux      reactredux      [C#]          Web/MVC/SPA
MVC ASP.NET Core with Vue.js                  vue             [C#]          Web/MVC/SPA
ASP.NET Core Web API                          webapi          [C#]          Web/WebAPI
Solution File                                 sln                           Solution

Examples:
    dotnet new mvc --auth None --framework netcoreapp1.1
    dotnet new classlib
    dotnet new --help

Steps 8- F:\Ng2DemoApp>
Steps 9- F:\Ng2DemoApp>dotnet new angular
Content generation time: 2690.9577 ms
The template "MVC ASP.NET Core with Angular" created successfully.

Steps 10- F:\Ng2DemoApp>dir
Volume in drive F is Disk Drive
 Volume Serial Number is C490-8A3E
 Directory of F:\Ng2DemoApp

17-05-2017  02.14 PM    <DIR>          .
17-05-2017  02.14 PM    <DIR>          ..
17-05-2017  02.14 PM             3,848 .gitignore
17-05-2017  02.14 PM               175 appsettings.json
17-05-2017  02.14 PM    <DIR>          ClientApp
17-05-2017  02.14 PM    <DIR>          Controllers
17-05-2017  02.14 PM                39 global.json
17-05-2017  02.14 PM             1,769 Ng2DemoApp.csproj
17-05-2017  02.14 PM             1,908 package.json
17-05-2017  02.14 PM               570 Program.cs
17-05-2017  02.14 PM             2,345 Startup.cs
17-05-2017  02.14 PM               358 tsconfig.json
17-05-2017  02.14 PM    <DIR>          Views
17-05-2017  02.14 PM               563 web.config
17-05-2017  02.14 PM             3,066 webpack.config.js
17-05-2017  02.14 PM             3,379 webpack.config.vendor.js
17-05-2017  02.14 PM    <DIR>          wwwroot
              11 File(s)         18,020 bytes
               6 Dir(s)  701,095,419,904 bytes free

Steps 11- F:\Ng2DemoApp>dotnet restore

Restoring packages for F:\Ng2DemoApp\Ng2DemoApp.csproj...
  Generating MSBuild file F:\Ng2DemoApp\obj\Ng2DemoApp.csproj.nuget.g.props.
  Generating MSBuild file F:\Ng2DemoApp\obj\Ng2DemoApp.csproj.nuget.g.targets.
  Writing lock file to disk. Path: F:\Ng2DemoApp\obj\project.assets.json
  Restore completed in 3.97 sec for F:\Ng2DemoApp\Ng2DemoApp.csproj.

  NuGet Config files used:
      C:\Users\Viainda\AppData\Roaming\NuGet\NuGet.Config
      C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config

  Feeds used:
      https://api.nuget.org/v3/index.json
      C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

Steps 12- F:\Ng2DemoApp>npm install

[    ..............] / fetchMetadata: sill mapToRegistry uri https://registry.npmjs.org/webpack-merge[    ..............] - fetchMetadata: sill mapToRegistry uri https://registry.npmjs.org/web[
--It is taking too much time to install and after successfully follow below steps

Steps 13- F:\Ng2DemoApp>start Ng2DemoApp.csproj

Steps 14-
After press F5 key on project to displays on your browser with “Hello, world!”.

Reference,


I hope you are enjoying with this post! Please share with you friends. Thank you!!

By Anil Singh | Rating of this article (*****)

Popular posts from this blog

nullinjectorerror no provider for httpclient angular 17

In Angular 17 where the standalone true option is set by default, the app.config.ts file is generated in src/app/ and provideHttpClient(). We can be added to the list of providers in app.config.ts Step 1:   To provide HttpClient in a standalone app we could do this in the app.config.ts file, app.config.ts: import { ApplicationConfig } from '@angular/core'; import { provideRouter } from '@angular/router'; import { routes } from './app.routes'; import { provideClientHydration } from '@angular/platform-browser'; //This (provideHttpClient) will help us to resolve the issue  import {provideHttpClient} from '@angular/common/http'; export const appConfig: ApplicationConfig = {   providers: [ provideRouter(routes),  provideClientHydration(), provideHttpClient ()      ] }; The appConfig const is used in the main.ts file, see the code, main.ts : import { bootstrapApplication } from '@angular/platform-browser'; import { appConfig } from ...

List of Countries, Nationalities and their Code In Excel File

Download JSON file for this List - Click on JSON file    Countries List, Nationalities and Code Excel ID Country Country Code Nationality Person 1 UNITED KINGDOM GB British a Briton 2 ARGENTINA AR Argentinian an Argentinian 3 AUSTRALIA AU Australian an Australian 4 BAHAMAS BS Bahamian a Bahamian 5 BELGIUM BE Belgian a Belgian 6 BRAZIL BR Brazilian a Brazilian 7 CANADA CA Canadian a Canadian 8 CHINA CN Chinese a Chinese 9 COLOMBIA CO Colombian a Colombian 10 CUBA CU Cuban a Cuban 11 DOMINICAN REPUBLIC DO Dominican a Dominican 12 ECUADOR EC Ecuadorean an Ecuadorean 13 EL SALVA...

39 Best Object Oriented JavaScript Interview Questions and Answers

Most Popular 37 Key Questions for JavaScript Interviews. What is Object in JavaScript? What is the Prototype object in JavaScript and how it is used? What is "this"? What is its value? Explain why "self" is needed instead of "this". What is a Closure and why are they so useful to us? Explain how to write class methods vs. instance methods. Can you explain the difference between == and ===? Can you explain the difference between call and apply? Explain why Asynchronous code is important in JavaScript? Can you please tell me a story about JavaScript performance problems? Tell me your JavaScript Naming Convention? How do you define a class and its constructor? What is Hoisted in JavaScript? What is function overloadin...

25 Best Vue.js 2 Interview Questions and Answers

What Is Vue.js? The Vue.js is a progressive JavaScript framework and used to building the interactive user interfaces and also it’s focused on the view layer only (front end). The Vue.js is easy to integrate with other libraries and others existing projects. Vue.js is very popular for Single Page Applications developments. The Vue.js is lighter, smaller in size and so faster. It also supports the MVVM ( Model-View-ViewModel ) pattern. The Vue.js is supporting to multiple Components and libraries like - ü   Tables and data grids ü   Notifications ü   Loader ü   Calendar ü   Display time, date and age ü   Progress Bar ü   Tooltip ü   Overlay ü   Icons ü   Menu ü   Charts ü   Map ü   Pdf viewer ü   And so on The Vue.js was developed by “ Evan You ”, an Ex Google software engineer. The latest version is Vue.js 2. The Vue.js 2 is very similar to Angular because Evan ...

React | Encryption and Decryption Data/Text using CryptoJs

To encrypt and decrypt data, simply use encrypt () and decrypt () function from an instance of crypto-js. Node.js (Install) Requirements: 1.       Node.js 2.       npm (Node.js package manager) 3.       npm install crypto-js npm   install   crypto - js Usage - Step 1 - Import var   CryptoJS  =  require ( "crypto-js" ); Step 2 - Encrypt    // Encrypt    var   ciphertext  =  CryptoJS . AES . encrypt ( JSON . stringify ( data ),  'my-secret-key@123' ). toString (); Step 3 -Decrypt    // Decrypt    var   bytes  =  CryptoJS . AES . decrypt ( ciphertext ,  'my-secret-key@123' );    var   decryptedData  =  JSON . parse ( bytes . toString ( CryptoJS . enc . Utf8 )); As an Example,   import   React   from ...