【问题标题】:Tasks settings of asp.net core project with typescript带有打字稿的asp.net核心项目的任务设置
【发布时间】:2016-06-16 10:30:12
【问题描述】:

我在 VS2015 中开发了带有 typescript 和 angular2 的 asp.net 核心应用程序。 我正在尝试将其移至 vscode。 我已经使用 dotnet 命令创建了新项目并开始设置依赖项、工具等。 我设置了调试.net核心应用程序的任务(它是由vs代码创建的) 现在我正在研究如何在监视模式下设置构建 typescript 并运行 gulp 任务。 VS 代码之前为我提供了为 TS 创建命令,但据我了解,只能有 1 个命令!那么,如何以最正确的方式让 asp.core 应用程序在调试以及 TS 编译、tslint 处理和 vscode 中的 gulp 任务的同时运行,并从所有这些工具输出到 vscode?​​p>

打字稿任务:

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "tsc",
"isShellCommand": true,
"args": ["-w", "-p", "."],
"showOutput": "silent",
"isWatching": true,
"problemMatcher": "$tsc-watch"
}

dotnet 的任务:

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
    {
        "taskName": "build",
        "args": [ ],
        "isBuildCommand": true,
        "showOutput": "silent",
        "problemMatcher": "$msCompile"
    }
]
}

【问题讨论】:

  • 您也应该添加 [asp.net-core] 标签。这样,当有人搜索 asp.net core 时,您的问题就会出现。仅使用 [asp.net-core-1.0] 标记,您的问题仅在人们在搜索中包含 1.0 时才会显示。

标签: typescript angular asp.net-core visual-studio-code asp.net-core-1.0


【解决方案1】:

因为您需要同时运行多个任务。我建议查看 npm 脚本。

npm 允许您在您的 packages.config 文件中创建命令。这是我在项目中使用的示例。查看“开始”命令。它将使用一个名为“concurrently”的包同时运行多个命令。在这种情况下,它正在运行 tsc:w,它在下面的另一个命令中定义,运行 lite 服务器,并运行我的 gulp 任务。

我在 VSCode 和 VSCode 终端 (CTRL + ~) 中点击调试,然后运行 ​​npm start,一切顺利。

packages.config

{
  "name": "queuedodge-site",
  "description": "web front end for queue dodge.",
  "private": true,
  "scripts": {
    "install": "tsc && gulp sass && gulp bundle",
    "start": "concurrently \"npm run tsc:w\" \"npm run lite\" \"gulp default\" ",
    "lite": "lite-server",
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings",
    "bundle": "gulp default"
  },
  "dependencies": {
    "@angular/common": "2.0.0-rc.1",
    "@angular/compiler": "2.0.0-rc.1",
    "@angular/core": "2.0.0-rc.1",
    "@angular/http": "2.0.0-rc.1",
    "@angular/platform-browser": "2.0.0-rc.1",
    "@angular/platform-browser-dynamic": "2.0.0-rc.1",
    "@angular/router": "2.0.0-rc.1",
    "@angular/router-deprecated": "2.0.0-rc.1",
    "@angular/upgrade": "2.0.0-rc.1",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.6",
    "systemjs": "^0.19.27",
    "zone.js": "^0.6.12",
    "bootstrap": "3.3.6",
    "es6-promise": "3.1.2",
    "es6-shim": "^0.35.0",
    "jquery": "2.2.0"
  },
  "devDependencies": {
    "concurrently": "^2.0.0",
    "lite-server": "^2.2.0",
    "typings": "1.0.4",
    "systemjs-builder": "0.15.16",
    "typescript": "^1.8.10",
    "gulp": "3.9.1",
    "gulp-sass": "2.2.0",
    "gulp-markdown": "1.2.0",
    "tslint": "3.5.0",
    "yargs": "4.7.0"
  }
}

【讨论】:

  • 好的,这是可能的。但看起来不是最好的选择。
  • 我一直在寻找同样的东西,并且还试图避免使用 node/npm,因为这会破坏让 dotnet 为项目服务的目的。最后我决定使用 webpack 来做服务/编译/打包……和其他事情。类似:gist.github.com/scottaddie/ec61dcedb47ff9113bf3#file-tasks-json 然后从 VS Code 命令pallete 运行任务
猜你喜欢
  • 2020-01-16
  • 2019-05-21
  • 2015-09-14
  • 1970-01-01
  • 2021-06-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-06
相关资源
最近更新 更多