ASP.NET 核心项目:如何防止 Typescript 编译

ASP.NET Core Project: How to keep Typescript from Compiling

我正在尝试将现有的 Angular 2 应用程序集成到 Visual Studio 中现有的 ASP.NET 核心项目中。这两个项目都是独立工作的,但是当我尝试在 Visual Studio 中编译 ASP.NET 核心项目时,我得到了一堆与 node_modules 文件夹中的文件相关的打字稿编译错误。

我如何:

我可以通过将 node_modules 文件夹移到项目根目录中来实现它,但这需要完全重新安排原始项目依赖项和构建文件,我希望避免这种情况。

-1-。您可以通过编辑项目文件 (.xproj) 来禁用 typescript 编译。添加此块:

<PropertyGroup>
    <TypeScriptCompileBlocked>True</TypeScriptCompileBlocked>
</PropertyGroup>   

-2-。为了防止编译器查看 node_modules 中的任何内容 - 在 tsconfig:

中使用 exclude
"exclude":[
  "node_modules"
]

* node_modules 的路径相对于 tsconfig.json