环境搭建:
1)node.js版本>5.0,NPM版本>3.0,TypeScript版本>2.0(全装最新版就好了)
2)安装NTVS 1.2(node tools for vs),TSVS dev 1.4(TS for VS)
3)构建package.json,tsconfig.json,gulp.js文件
  1、package.json

{
"name": "template.angular2",
"version": "1.0.0",
"licenses": [
{
"type": "MIT",
"url": "https://github.com/angular/angular.io/blob/master/LICENSE"
}
],
"dependencies": {
"@angular/common": "~2.1.1",
"@angular/compiler": "~2.1.1",
"@angular/core": "~2.1.1",
"@angular/forms": "~2.1.1",
"@angular/http": "~2.1.1",
"@angular/platform-browser": "~2.1.1",
"@angular/platform-browser-dynamic": "~2.1.1",
"@angular/router": "~3.1.1",
"@angular/upgrade": "~2.1.1",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.0-beta.12",
"systemjs": "0.19.39",
"zone.js": "^0.6.25"
},
"devDependencies": {
"@types/core-js": "^0.9.34",
"@types/node": "^6.0.45",
"gulp": "^3.9.1",
"del": "^2.2.2"
}
}

    2、tsconfig.json

{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
//需要这个才能使用注释器
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"compileOnSave": true
}

    3、gulp.js

var gulp = require('gulp');
var del = require('del'); var paths = {
angularPatch: [
"node_modules/core-js*/**/*",
"node_modules/zone.js*/**/*",
"node_modules/reflect-metadata*/*.js",
"node_modules/reflect-metadata*/*.map",
"node_modules/systemjs*/dist*/*.js",
"node_modules/systemjs*/dist*/*.map"
],
angularSrc: [
"node_modules/@angular/core/bundles/core.umd.js",
"node_modules/@angular/common/bundles/common.umd.js",
"node_modules/@angular/compiler/bundles/compiler.umd.js",
"node_modules/@angular/platform-browser/bundles/platform-browser.umd.js",
"node_modules/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js",
"node_modules/@angular/http/bundles/http.umd.js",
"node_modules/@angular/router/bundles/router.umd.js",
"node_modules/@angular/forms/bundles/forms.umd.js",
"node_modules/@angular/upgrade/bundles/upgrade.umd.js"
//"node_modules/",
],
rxjsSrc: "node_modules/rxjs/**/*",
TSSrc:"Scripts/**/*.js",
TSTarget:"wwwroot/js",
Tartget:"wwwroot/lib"
}
//手工构建一次
gulp.task("copyangularfiles", function () {
//gulp.src(paths.angularSrc).pipe(gulp.dest(paths.Tartget)); paths.angularSrc.forEach(function (path) {
var tpath = path.replace("node_modules", paths.Tartget).split('/');
gulp.src(path).pipe(gulp.dest(tpath.slice(, tpath.length - ).join('/')));
});
gulp.src(paths.rxjsSrc).pipe(gulp.dest(paths.Tartget + "/rxjs"));
gulp.src(paths.angularPatch).pipe(gulp.dest(paths.Tartget + "/patch")); });
//加入任务->绑定->生成前
gulp.task("copytsfiles", function () {
gulp.src(paths.TSSrc).pipe(gulp.dest(paths.TSTarget));
}) gulp.task('default', ['copytsfiles'], function () {
// place code for your default task here
});
4)在项目根目录建立 Scripts 文件夹
5)在wwwroot文件夹建立systemjs.config.js
/**
* System configuration for Angular samples
* Adjust as necessary for your application needs.
*/
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'lib/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: 'js',
// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
// other libraries
'rxjs': 'npm:rxjs'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
}
}
});
})(this);
6)修改Views/Shared/_Layout.cshtml,删除对site.js的引用
7)修改Views/Home/Index.cshtml,增加/构建@section scripts 脚本段
@section scripts{

    <!-- . Load libraries -->
<!-- Polyfill(s) for older browsers --> <script src="~/lib/patch/core-js/client/shim.min.js"></script> <script src="~/lib/patch/zone.js/dist/zone.js"></script> <script src="~/lib/patch/reflect-metadata/Reflect.js"></script> <script src="~/lib/patch/systemjs/dist/system.src.js"></script>
<!-- . Configure SystemJS --> <script src="systemjs.config.js"></script> <script>
System.import('app').catch(function (err) { console.error(err); });
</script> }
8)环境搭建完成,程序入口文件 wwwroot/js/main.js(Scripts/main.ts)

.Net Core + Angular2 环境搭建的更多相关文章

  1. .Net Core(一)环境搭建与基本使用

    .Net Core(一)环境搭建与基本使用 一.系统配置 a) Linux下如果想要打开类似任务管理器,可以使用top命令,在控制台会动态刷新CPU和内存占用.进程等信息.vmstat和free命令可 ...

  2. .net core运行环境搭建 linux + windows

    ---------------------------------------linux------------------------------------------------- 一.添加do ...

  3. 记一次Angular2环境搭建及My First Angular App小demo呈现

    参考连接?不如说是照搬链接.AngularJs官网地址快速起步地址. 对于一个一直只是用jq,偶尔学习点Knockout js,了解一点mvvm结构的前端来说,学习Angular2还是有点困难的.好了 ...

  4. Linux下.Net Core+Nginx环境搭建小白教程

    前言 对于接触.Net Core的我们来说之前从未接触过Linux,出于资源和性能及成本的考虑我们可能要将我们的环境搬到Linux下,这对于我们从未接触过Linux的童鞋们来说很棘手,那么我今天将带你 ...

  5. dotNet Core开发环境搭建及简要说明

    一.安装 .NET Core SDK 在 Windows 上使用 .NET Core 的最佳途径:使用Visual Studio. 免费下载地址: Visual Studio Community 20 ...

  6. angular2环境搭建

    Angular2.x与Angular1.x完全不同,Angular2.x是不兼容Angular1.x的,所在在框架的构造上,它们是完全不同的.在Angular2.x中,因为其是基于ES6来开发的,所以 ...

  7. [.net 面向对象程序设计深入](9).NET Core 跨平台开发环境搭建

    [.net 面向对象程序设计深入](9).NET Core 跨平台开发环境搭建 1.概述 读前必备:认识.NET Core 上篇介绍了.NET 新的生态环境:包括.NET Framework..NET ...

  8. webpack+angular2开发环境搭建

    升级版之webpack4 + angular5脚手架demo详见: http://www.cnblogs.com/xudengwei/p/8852257.html 刚搭建完一个webpack+angu ...

  9. Angular2+学习第2篇 cli 环境搭建过程

    Angular-cli是angular团队针对Angular2提供的脚手架,用于环境搭建,运行等:具体参考Angular-cli GitHub Angular的启动过程,需要先回答三个问题: 启动时加 ...

随机推荐

  1. AE调用GP工具的方法(转)

    第一,首先要明确自己需要调用arctoolbox里面的什么工具,实现什么样的功能. 第二,按照需求看看在arctoolbox工具中是怎么实现功能的,然后确定需要的数据源. 第三,编写command或t ...

  2. Sql Server 删除所有表(转)

    http://www.cnblogs.com/jys509/p/3589468.html  首先必须要清空所有表的外键 DECLARE c1 cursor for select 'alter tabl ...

  3. 日期控件,layui

    <link rel="stylesheet" href="<%=path%>/layui/css/layui.css" type=" ...

  4. iOS:使用代理模式监听开关状态改变事件

    记一次解决跨控制器监听开关状态改变的尝试. 为了统一设置UITableViewCell里的内容,自定义了UITableViewCell类的一个基类,命名为SettingCell.SettingCell ...

  5. Vue2.X的路由管理记录之 钩子函数(切割流水线)

    $route可以在子组件任何地方调用,代表当前路由对象,这个属性是只读的,里面的属性是 immutable(不可变) 的,不过你可以 watch(监测变化) 它. 导航和钩子函数: 导航:路由正在发生 ...

  6. opencv用imread( argv[1], 1)读取图片

    显示一幅图:主要是运用功能:imread namedWindow imshowimread:从字面意思我们就可以看懂,用来读取图片的:namedWindow:显然,我们也可以看到这是用来命名窗口名称的 ...

  7. js 判断IE浏览器,包含IE6/7/8/9

    //判断IE6-9的版本,num可取值为6/7/8/9//若不给参数num,仅判断浏览器是否为IE,不判断版本 var isIE = function (num) { if(arguments.len ...

  8. FZU 2150 Fire Game

    Fire Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit St ...

  9. PLSQL大数据生成规则

    数据定义 数据定义决定了被生成的数据.如果要创建简单的字符,可以在两个方括号之间输入字符定义:[数据] 数据可以是下列预先确定的集的混合体:           •  a: a..z (小写字符)   ...

  10. 常用的web功能测试方法

    功能测试就是对产品各功能进行验证,根据功能测试用例,逐项测试,检查产品是否达到用户要求功能,即是否满足需求.常用的测试方法如下: 1.页面连接检查:每一个连接是否都有对应的页面,并且页面之间切换正确. ...