[Archived] This repository has been archived
Перейти к файлу
Nate McMaster ea3a7bc897
Pin version variables to the ASP.NET Core 2.1.2 baseline
This reverts our previous policy of cascading versions on all servicing updates.
This moves variables into the 'pinned' section, and points them to the latest
stable release (versions that were used at the time of the 2.1.2 release).
2018-07-12 11:54:22 -07:00
build Pin version variables to the ASP.NET Core 2.1.2 baseline 2018-07-12 11:54:22 -07:00
samples/misc Update samples and tests to target netcoreapp2.1 2017-11-16 16:59:15 -08:00
src Set 2.1 baselines 2018-06-14 11:29:25 -07:00
templates SPA templates have now moved to the aspnet/templating repo 2017-09-07 13:28:18 +01:00
.appveyor.yml Update dependencies.props to 2.1.0-preview-28193, build tools to 2.1.0-preview1-1010 [ci skip] 2018-01-31 15:01:11 -08:00
.gitattributes Normalise trailing whitespace and line endings everywhere 2016-03-01 01:10:43 +00:00
.gitignore Pin tool and package versions to make builds more repeatable 2017-11-03 15:09:19 -07:00
.travis.yml Update dependencies.props to 2.1.0-preview-28193, build tools to 2.1.0-preview1-1010 [ci skip] 2018-01-31 15:01:11 -08:00
CONTRIBUTING.md Create CONTRIBUTING.md 2015-11-01 17:26:21 -08:00
Directory.Build.props Use MSBuild to set NuGet feeds instead of NuGet.config 2017-11-20 12:43:30 -08:00
Directory.Build.targets Set NETStandardImplicitPackageVersion via dependencies.props 2018-04-19 16:40:07 -07:00
JavaScriptServices.sln Add new Microsoft.AspNetCore.SpaServices.Extensions package to host new runtime functionality needed for updated templates until 2.1 ships 2017-11-09 10:09:13 -08:00
LICENSE.txt Update LICENSE.txt text 2017-07-03 14:06:26 -07:00
NuGet.config Use MSBuild to set NuGet feeds instead of NuGet.config 2017-11-20 12:43:30 -08:00
NuGetPackageVerifier.json Add NuGetPackageVerifier 2018-03-21 10:35:29 -07:00
README.md Update README.md 2017-09-07 13:54:03 +01:00
build.cmd Update bootstrappers 2017-09-22 12:13:00 +01:00
build.sh Update bootstrappers 2017-09-22 12:13:00 +01:00
korebuild-lock.txt Updating dependencies to 2.1.2 and adding a section for pinned variable versions 2018-07-11 18:49:03 -07:00
korebuild.json Branching for 2.1.0-rc1 2018-04-16 16:58:32 -07:00
run.cmd Update bootstrappers 2017-09-22 12:13:00 +01:00
run.ps1 Update bootstrappers 2017-12-01 12:29:52 -08:00
run.sh Update bootstrappers 2017-12-01 12:29:52 -08:00
version.props Reverting version from 2.1.2 back to 2.1.1 2018-07-11 15:06:34 -07:00

README.md

JavaScriptServices

AppVeyor: AppVeyor

This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the Home repo.

What is this?

JavaScriptServices is a set of client-side technologies for ASP.NET Core. It provides infrastructure that you'll find useful if you:

  • Use Angular / React / Vue / Aurelia / Knockout / etc.
  • Build your client-side resources using Webpack.
  • Execute JavaScript on the server at runtime.

Read Building Single Page Applications on ASP.NET Core with JavaScriptServices for more details.

This repo contains:

  • A set of NuGet/NPM packages that implement functionality for:
    • Invoking arbitrary NPM packages at runtime from .NET code (docs)
    • Server-side prerendering of SPA components (docs)
    • Webpack dev middleware (docs)
    • Hot module replacement (HMR) (docs)
    • Server-side and client-side routing integration (docs)
    • Server-side and client-side validation integration
    • "Lazy loading" for Knockout apps
  • Samples and docs

It's cross-platform (Windows, Linux, or macOS) and works with .NET Core 2.0 or later.

Creating new applications

Prerequisites:

With these prerequisites, you can immediately create new ASP.NET Core applications that use Angular, React, or React+Redux without having to install anything extra.

Option 1: Creating Angular/React/Redux applications from the command line (cross-platform)

In an empty directory, run (for example) dotnet new angular. Other supported SPA frameworks include React and React+Redux. You can see the list of available SPA templates by running dotnet new spa.

Once the generator has run and restored all the dependencies, you can start up your new ASP.NET Core SPA:

npm install
dotnet run 

Option 2: Creating Angular/React/Redux applications using Visual Studio 2017 Update 3 or later (Windows only)

Using the File->New Project dialog, select ASP.NET Core Web Application. You will then be offered the option to create an application with Angular, React, or React+Redux. When the application is created, you can build and run it in the normal way.

More info and other SPA frameworks

For a more detailed (albeit somewhat outdated) walkthrough, see getting started with the aspnetcore-spa generator.

If you want to build an ASP.NET Core application with Aurelia, Knockout, or Vue, you can use the Microsoft.AspNetCore.SpaTemplates package. On the command line, run dotnet new --install Microsoft.AspNetCore.SpaTemplates. Then you will be able to run dotnet new aurelia (or dotnet new vue, etc.) to create your new application.

Adding to existing applications

If you have an existing ASP.NET Core application, or if you just want to use the underlying JavaScriptServices packages directly, you can install these packages using NuGet and NPM:

  • Microsoft.AspNetCore.NodeServices
    • This provides a fast and robust way for .NET code to run JavaScript on the server inside a Node.js environment. You can use this to consume arbitrary functionality from NPM packages at runtime in your ASP.NET Core app.
    • Most applications developers don't need to use this directly, but you can do so if you want to implement your own functionality that involves calling Node.js code from .NET at runtime.
    • Find documentation and usage examples here.
  • Microsoft.AspNetCore.SpaServices
    • This provides infrastructure that's generally useful when building Single Page Applications (SPAs) with technologies such as Angular or React (for example, server-side prerendering and webpack middleware). Internally, it uses the NodeServices package to implement its features.
    • Find documentation and usage examples here

There were previously other packages called Microsoft.AspNetCore.AngularServices and Microsoft.AspNetCore.ReactServices but these are not currently needed - all applicable functionality is in Microsoft.AspNetCore.SpaServices, because it's sufficiently general.

If you want to build a helper library for some other SPA framework, you can do so by taking a dependency on Microsoft.AspNetCore.SpaServices and wrapping its functionality in whatever way is most useful for your SPA framework.

Samples

The samples directory contains examples of:

  • Using the JavaScript services family of packages with Angular and React.
  • A standalone NodeServices usage for runtime code transpilation and image processing.

To run the samples:

  • Clone this repo
  • At the repo's root directory (the one containing src, samples, etc.), run dotnet restore
  • Change directory to the sample you want to run (for example, cd samples/angular/MusicStore)
  • Restore Node dependencies by running npm install
    • If you're trying to run the Angular "Music Store" sample, then also run gulp (which you need to have installed globally). None of the other samples require this.
  • Run the application (dotnet run)
  • Browse to http://localhost:5000

Contributing

If you're interested in contributing to the various packages, samples, and project templates in this repo, that's great!

Before working on a pull request, especially if it's more than a trivial fix (for example, for a typo), it's usually a good idea first to file an issue describing what you're proposing to do and how it will work. Then you can find out if it's likely that such a pull request will be accepted, and how it fits into wider ongoing plans.