Angular 2

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!!

ANIL SINGH

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - http://www.code-sample.com and http://www.code-sample.xyz
My Books - Buy Books Online at Best Prices

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.