From 0043540739eb07b255a229927f7c4aa4a56fd241 Mon Sep 17 00:00:00 2001 From: Maxim Tebenev Date: Sun, 17 Dec 2017 13:46:46 +0300 Subject: [PATCH] Readme --- README.md | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c399e1d..e52cd16 100644 --- a/README.md +++ b/README.md @@ -1 +1,67 @@ -# ngaspnetcore +# NgAspNetCore + +This is set of packages and utilities for building Angular applications with ASP.Net Core. Find more information at http://tebenev.com/technical/asp-net-core-angular-apps-ngaspnetcore/ + +## Step by step usage guide + +First, add NgAspNetCore feed https://www.myget.org/F/ngaspnetcore/api/v3/index.json either in Visual Studio or using NuGet.config file in your solution. + +### Creating client application: + +1. Create class library project for the client application using 'Class Library (.NET Core)' template +2. You may want to add the following property group to prevent compiling TypeScript by IDE: +```xml + + netcoreapp2.0 + true + Latest + +``` + +3. Create angular application in the class library with Angular-CLI: + +```bash +ng new ClientAppPackage1 --skip-commit --skip-git --style scss --directory . +``` + +This will set up the NPM package and the Angular application. + +4. Optionally add property group in csproj file to not show node_modules in Visual Studio solution explorer - that will greatly speed up projects loading in the IDE. + +```xml + + node_modules/**;$(DefaultItemExcludes) + +``` + +5. Add package reference to **NgAspNetCore.Client.Targets** package + + +### Creating the host app (server): + +1. Create project for the server using ASP.Net Core Web application template +2. Add package reference to **NgAspNetCore.Server.Targets** +3. Add reference to the client project (that you have created using steps above) + +After that you can start building your solution. Note that client application built automatically and normally you will see the following in Build Output: +```bash +2>Performing client application build: ClientAppPackage1... +4>Date: 2017-11-21T14:40:13.434Z +4>Hash: 47844129580702182c18 +4>Time: 11429ms +4>chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered] +.... +``` + +### Rendering client application in Razor view + +When you build your host project with NgAspNetCore.Server.Targets package, it copies client app files in wwwroot/dist/%ClientAppName%. In the steps above it would be located in wwwroot/dist/ClientAppPackage1 folder. Remember that the client app eventually is just built WebPack bundle files. All we need to render the client app is to include the scripts in our Razor view like this: + +```xml + + + + + + +``` \ No newline at end of file