typescript 构建错误 MSB600“tsc.exe”退出,代码 2

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36235208/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 03:22:45  来源:igfitidea点击:

Build error MSB600 "tsc.exe" exited with code 2

c#asp.nettypescript

提问by D?ivo Jeli?

Can anyone give any insight. Couldn't find any information about this. -Asp.net 5 project- Visual studio 2015 Encountered the below error

任何人都可以提供任何见解。找不到有关此的任何信息。-Asp.net 5 项目- Visual Studio 2015 遇到以下错误

Error MSB6006 "tsc.exe" exited with code 2. C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TypeScript\Microsoft.TypeScript.targets 213

错误 MSB6006“tsc.exe”退出,代码 2。C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TypeScript\Microsoft.TypeScript.targets 213

EDIT: This is line 213 of the Microsoft.TypeScript.targets file

编辑:这是 Microsoft.TypeScript.targets 文件的第 213 行

  <VsTsc
  ToolPath="$(TscToolPath)"
  ToolExe="$(TscToolExe)"
  TSConfigFile="%(ConfigFiles.Identity)"
  YieldDuringToolExecution="$(TscYieldDuringToolExecution)"
  ProjectDir="$(ProjectDir)"
  ToolsVersion="$(TypeScriptToolsVersion)"
  TypeScriptCompileBlocked="$(TypeScriptCompileBlocked)"
  ComputeOutputOnly="false">

I have succeded to compile with gulp-typescript library.

我已成功使用 gulp-typescript 库进行编译。

[16:27:47] Starting 'build-ts'... Process terminated with code 0.

[16:27:50] TypeScript: 4 semantic errors.

[16:27:50] TypeScript: emit succeeded (with errors)

[16:27:50] Finished 'build-ts' after 3.49 s

[16:27:47] 开始'build-ts'...进程以代码 0 终止。

[16:27:50] TypeScript:4 个语义错误。

[16:27:50] TypeScript:发射成功(有错误)

[16:27:50] 3.49 秒后完成了“build-ts”

回答by vmg

There may be multiple reasons behind this error. The problem is VS does not show exact error returned by TypeScript compiler.

此错误背后可能有多种原因。问题是 VS 没有显示 TypeScript 编译器返回的确切错误。

I wrote a blog post that explains small trick to get detailed error message, I hope it will be useful for someone: http://the-coderok.azurewebsites.net/2016/07/13/Resolve-the-Error-MSB6006-tsc-exe-exited-with-code-2-build-error-in-Visual-Studio-2015/

我写了一篇博文,解释了获取详细错误消息的小技巧,希望对某人有用:http: //the-coderok.azurewebsites.net/2016/07/13/Resolve-the-Error-MSB6006- tsc-exe-exited-with-code-2-build-error-in-Visual-Studio-2015/

回答by Paco Ferre

If you are having problems with ASP.NET Core xproj compilation and don't have any .ts file, you could disable Typescript compilation modifying .xproj file and adding:

如果您在 ASP.NET Core xproj 编译时遇到问题并且没有任何 .ts 文件,您可以禁用 Typescript 编译修改 .xproj 文件并添加:

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>

Inside the first

第一个里面

<PropertyGroup>
    <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
    ...
</PropertyGroup> 

回答by Gopi

After updating TypescriptToolsVersion to 1.8

将 TypescriptToolsVersion 更新为 1.8 后

 <TypeScriptToolsVersion>1.8</TypeScriptToolsVersion>

Change Typescript Targets paths to include TypeScriptionVersion location. like below.

更改 Typescript 目标路径以包含 TypeScriptionVersion 位置。像下面。

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript$(TypeScriptToolsVersion)\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript$(TypeScriptToolsVersion)\Microsoft.TypeScript.targets')" />

回答by Michael Washington

My answer was that I had a project that was using TypeScript 2.0 with Visual Studio 2015 that I opened in Visual Studio 2013. Opening it in Visual Studio 2015 fixed the problem for me.

我的回答是,我有一个在 Visual Studio 2013 中打开的使用 TypeScript 2.0 和 Visual Studio 2015 的项目。在 Visual Studio 2015 中打开它为我解决了这个问题。

回答by Nadav Hury

Changing my tsconfig.json fixed that for me. it looks like:

更改我的 tsconfig.json 为我解决了这个问题。看起来像:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "sourceMap": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "outDir": "wwwroot/app/",
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true
  },
  "filesGlob": [
    "node_modules/**",
    "wwwroot/**/*",
    "typings/**/*"
  ],
  "compileOnSave": false

回答by James

I had the same issue, and seeing you fixed yours by your comment on your question by removing the bad tsconfig.json lead me to find the cause of my error too.

我遇到了同样的问题,看到你通过删除坏的 tsconfig.json 对你的问题发表评论来解决你的问题,这让我也找到了错误的原因。

I had this line in my tsconfig.json in efforts to get my sourcemap files to work with my browser again.

我在我的 tsconfig.json 中有这一行是为了让我的源映射文件再次与我的浏览器一起工作。

"sourceRoot": "/"

Removing this line fixed the issue (and hadn't been fixing my sourcemap issue it transpired anyway)

删除这一行解决了这个问题(并且一直没有解决我的源映射问题,它无论如何都发生了)

I guess if you're hitting this issue you have a bad tsconfig.json compilerOptions

我想如果你遇到了这个问题,你的 tsconfig.json 文件很糟糕 compilerOptions