2016-03-02 69 views
4

我正在使用VS2015,并试图在ASP.NET Core项目中使用TypeScript生成一个Angular应用程序,但无论我尝试什么,我都无法将我的Angular虚拟项目转储到wwwroot文件夹中,尽管VS2015将其识别为TypeScript虚拟项目。这里是我的项目结构:Visual Studio 2015不将TypeScript编译为ASP.NET Core项目的一部分?

enter image description here

这里是我的tsconfig.json文件:

{ 
    "compileOnSave": true, 
    "compilerOptions": { 
    "noImplicitAny": false, 
    "noEmitOnError": true, 
    "removeComments": false, 
    "sourceMap": true, 
    "target": "es5", 
    "module": "system", 
    "experimentalDecorators": true, 
    "moduleResolution": "node", 
    "outDir": "../../wwwroot/" 
    }, 
    "exclude": [ 
    "node_modules", 
    "wwwroot" 
    ] 
} 

VS不会自动编译这个,甚至运行在一个文件中的命令行结果npm run tsc:w main.ts未找到错误。我如何获得我的ts文件来构建?

+0

几周前,我用Angular2和ts浏览过类似的话题。尽管我有点像Visual Studio纯粹主义者将所有内容与c#后端集成在一起,但很多阅读令人惊讶地说服我尝试VS Code for前端和Angular。对我来说,它变得更加无缝集成角度,和一些非常好的惊喜与舒适的前端工作(特别是与vs相比,速度的突破速度) – Turo

+0

@Turo没有可悲的选择 – ReactingToAngularVues

+0

我有同样的问题vs2015更新3.对我来说,解决方案是手动设置TypeScript版本为1.7或更高版本: http://stackoverflow.com/questions/39021808/vs2015-adding-watch-true-to-tsconfig-json-causing- jserrorscriptexception-0x/39022452#39022452 – Dudi

回答

0

@EchoLogic,尝试将您的文件夹重命名为脚本,它应该工作。

+0

@SambhavSharma这不是从作者请求信息。它提出了一个解决方案。它*是*答案。 – Servy

0

你的outdir是相对于tsconfig.json,所以你的路径应该是这样的:../wwwroot/。这里是我自己的tsconfig.json的一个例子:

{ 
"compilerOptions": { 
"target": "es5", 
"module": "commonjs", 
"moduleResolution": "node", 
"sourceMap": true, 
"emitDecoratorMetadata": true, 
"experimentalDecorators": true, 
"removeComments": false, 
"noImplicitAny": false, 
"outFile": "../wwwroot/app/app.js" 
    }, 
"compileOnSave": true, 
"files": [ 
    "../typings/main.d.ts", 
    "app.module.ts", 
    "app.config.ts", 
    "home.controller.ts", 
    "myTeam.controller.ts" 
    ]} 

我也喜欢通过gulp来构建打字稿。我已经发布了关于如何做到这两篇文章:

在这里,你可以找到关于如何配置ASP.NET应用程序的核心编译打字稿一个完整的一步一步的指导: ASP.NET Core: modify an Angular app to use typescript

怎么办与Gulp工作流程相同: ASP.NET Core: Building Typescript with Gulp

相关问题