我有一个ASP。NET核心项目,我得到这个错误时,我试图构建它:

error TS18003: Build:No inputs were found in config file 'Z:/Projects/client/ZV/src/ZV/Scripts/tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["../wwwroot/app","node_modules/*"]'.
1>         The command exited with code 1.
1>       Done executing task "VsTsc" -- FAILED.

这是我的tsconfig。json文件:

{
  "compileOnSave": true,
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es5", "dom" ],
    "module": "commonjs",
    "moduleResolution": "node",
    "noEmitOnError": true,
    "noImplicitAny": false,
    "outDir": "../wwwroot/app/",
    "removeComments": false,
    "sourceMap": true,
    "target": "es6"
  },
  "exclude": [
    "../wwwroot/app",
    "node_modules/*"
  ]
}

这是bug还是我做错了什么?我最近把Visual Studio 2015升级到3。有人以前遇到过这种情况吗?


当前回答

我得到了同样的错误,在我的情况下,这是因为vscode不能识别.ts文件。

它将其视为文本文件,我不得不重命名它以删除一个字母,并将其添加回来以使其工作。

其他回答

我在根目录(visual studio)中添加了以下内容

{
  "compilerOptions": {
    "allowJs": true,
    "noEmit": true,
    "module": "system",
    "noImplicitAny": true,
    "removeComments": true,
    "preserveConstEnums": true,
    "sourceMap": true
  },
  "include": [
    "**/*"
  ],
  "exclude": [
    "assets",
    "node_modules",
    "bower_components",
    "jspm_packages"
  ],
  "typeAcquisition": {
    "enable": true
  }
}

当您创建tsconfig。Json文件的TSC——init,然后注释输入和输出文件目录。这就是错误的根本原因。

要解决这个问题,取消注释这两行:

"outDir": "./", 
"rootDir": "./", 

在取消注释后,它最初看起来像上图。

但是我所有的。ts脚本都在src文件夹中。我指定了/src。

"outDir": "./scripts", 
"rootDir": "./src", 

请注意,您需要在rootDir中指定.ts脚本的位置。

根据这篇文章,如果你不想编译TypeScript,在你的.csproj文件中禁用它。

只需在你的.csproj文件中添加以下一行:

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>

将index.js更改为index。它为我修复了这个错误。(在此之前我没有任何.ts文件)。

注意:记住在你引用index.js的任何地方都要改成index。当然,除非你引用你的主文件。按照惯例,这可能在你的lib或dist文件夹中。 我的tsconfig.json:

{
  "compilerOptions": {
    "target": "es2016",
    "module": "commonjs",
    "outDir": "./dist",
    "strict": true,
    "esModuleInterop": true,
    "inlineSourceMap": true,
    "noImplicitAny": false
  }
}

我的outDir是。/dist,所以我在包中引用了main。"dist/index.js"

将一个.ts文件添加到项目根目录(与。tsconfig文件)。

因此,在我的例子中,我添加了一个.ts文件,并将其命名为main.ts。

在我的.tsconfig文件中,我包含了main.ts。

{
  "include": ["src/**/*", "main.ts"]
}