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# - Update 1 RC 降级为 CTP 后,LINQ to Entities 仅支持转换 EDM 基元或枚举类型

asp.net - WCF 同步与异步

typescript - 通过 typescript 中的动态键字符串访问 react native 样式表成员

asp.net - 在 ashx 处理程序的代码中强制执行 SSL

angular - TypeScript 中 private 的使用

typescript - 对键及其类型使用通用 keyof 进行设置操作

git - 工作项、 pull 请求菜单在 Visual Studio 中不可见

visual-studio-2015 - 我可以在没有 Internet 连接的情况下使用 Visual Studio 2015 吗?

javascript - 使用 Javascript 检查 ASP.NET 中的 Div 可见性

c# - 网络凭据未保存在 CredentialCache 中