簡體   English   中英

使用打字稿的asp.net核心項目的任務設置

[英]Tasks settings of asp.net core project with typescript

我有一個asp.net核心應用程序,在VS2015中開發了typescript和angular2。 我正在嘗試將其移至vscode。 我用dotnet命令創建了新項目並開始設置依賴項,工具等。我設置了調試.net核心應用程序的任務(它是由vs代碼創建的)現在我正在研究如何設置構建打字稿在監視模式下運行gulp任務。 VS代碼早先為我提供了為TS創建命令,但據我所知,只能有1個命令! 那么如何以最正確的方式使用調試以及調試中的TS編譯,tslint處理和gulp任務以及從所有這些工具輸出到vscode來運行asp.core應用程序?

打字稿的任務:

{
// 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"
    }
]
}

因為您需要同時運行多個任務。 我建議查看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"
  }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM