asp.net - VS 2015 和 msbuild 抑制 typescript 错误

标签 asp.net typescript visual-studio-2015 msbuild

在我使用的解决方案中,有一个项目大量使用 typescript ,我试图让这个项目通过构建,以便在其上运行 msbuild..

已尝试编辑 .csproj使用 typescript 的项目文件并向其添加属性 <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>

<PropertyGroup>元素,但这没有帮助。 也试过:<TypeScriptEnabled>false</TypeScriptEnabled> 这也没有帮助。

如何设置 VS2015 忽略 typescript 以及我可以向“msbuild”命令添加什么以使其忽略 typescript还有吗?

这是构建后的错误列表选项卡: Error List

这是构建后的输出选项卡: enter image description here

最佳答案

How can i set VS2015 to ignore typescript and also what can i add to 'msbuild' command for it to ignore typescript also?

不确定该帖子中所有示例对您不起作用的原因,我测试了属性 <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>在 Visual Studio 2015 上运行良好。为确保您正确操作,我想提供有关此方法的详细信息,您可以查看。

添加节点:

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>

进入第一个<PropertyGroup>在 .csproj 文件中,如下所示:

<PropertyGroup>
  <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
  <ProductVersion>
  </ProductVersion>
  ....
  <NuGetPackageImportStamp>
  </NuGetPackageImportStamp>
  <TypeScriptToolsVersion>1.8</TypeScriptToolsVersion>
  <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
</PropertyGroup>

保存此设置后,重新加载项目,重新构建项目(使用 MSBuild 项目构建输出详细信息到 Detail),您会在输出窗口中注意到构建日志:

TypeScript compile is skipped because the TypeScriptCompileBlocked property is set to 'true'.

enter image description here

注:TypeScript tools for Visual Studio的版本是 1.8.36.0

更新:

then i looked at the "Output" tab but there is no line that contains the text "typescript" the lines there are not related to it

您应该将 MSBuild 项目构建输出详细程度更改为详细信息,然后检查输出窗口中的日志:

enter image description here

我想提供另一种方法来抑制 typescript 错误:

选择 TypeScript 文件并将其 ContentType 更改为“Content”而不是“TypeScriptCompile”,这样语言服务就不会给您错误。

  <ItemGroup>
    <Content Include="Test.ts" />
  </ItemGroup>

评论更新:

如果您希望在从 MSBuild 命令执行构建时抑制 TS 错误,您可以将属性添加为 /p:TypeScriptCompileBlocked=true :

详细信息:

  1. 打开 cmd 并将路径切换到 MSBuild:C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin

  2. 执行命令:msbuild "YourProject.csproj" /p:Platform=x64 /p:TypeScriptCompileBlocked=true

关于asp.net - VS 2015 和 msbuild 抑制 typescript 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46037063/

相关文章:

c# - 如何以编程方式加载 aspx 文件?

typescript - 在 TypeScript 中,为什么可以将 `null` 分配给类型为 `undefined` 的变量,反之亦然

javascript - echarts:如何在条形图上添加正态分布曲线?

c# - 代码隐藏中的 GridView RowUpdating SqlDataSource.Update

asp.net - Asp.Net Webform 中的 SignalR 和 Knockout JS

javascript - JS/TS 在不删除分隔符的情况下通过分隔符拆分字符串

python - Django 没有名为 "compressor"的模块

c++ - VC++ 2015 没有链接,但 VC++ 2012 有

c# - ASP.NET vNext - MissingMethodException : Method not found: Microsoft. CodeAnalysis.Diagnostic> EmitResult.get_Diagnostics()'

asp.net - 从 C# 代码增加 Http Runtime MaxRequestLength