如何将 VS2015 设置为忽略打字稿,以及我可以在“msbuild”命令中添加什么以使其也忽略打字稿?
不确定为什么该帖子中的所有示例都不适用于您,我在 Visual Studio 2015 上测试了 <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> 属性,它工作正常。为了确保您正确操作,我想提供有关此方法的详细信息,您可以查看。
添加节点:
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
进入 .csproj 文件中的第一个 <PropertyGroup>,如下所示:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
....
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TypeScriptToolsVersion>1.8</TypeScriptToolsVersion>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
</PropertyGroup>
保存此设置后,重新加载您的项目,重新构建项目(使用 MSBuild 项目构建输出详细信息),您会在输出窗口中看到构建日志:
TypeScript 编译被跳过,因为 TypeScriptCompileBlocked 属性设置为“true”。
注意:TypeScript tools for Visual Studio的版本是1.8.36.0
更新:
然后我查看了“输出”选项卡,但没有包含的行
文本“打字稿”与它无关的行
您应该将 MSBuild 项目构建输出详细程度更改为详细信息,然后在输出窗口中检查日志:
我想提供另一种抑制打字稿错误的方法:
选择 TypeScript 文件并将其 ContentType 更改为 'Content' 而不是 'TypeScriptCompile',然后语言服务应该不会给你错误。
<ItemGroup>
<Content Include="Test.ts" />
</ItemGroup>
评论更新:
如果您想在从 MSBuild 命令执行构建时抑制 TS 错误,可以将属性添加为 /p:TypeScriptCompileBlocked=true:
详细信息:
打开一个cmd并切换到MSBuild的路径:C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin
执行命令:msbuild "YourProject.csproj" /p:Platform=x64 /p:TypeScriptCompileBlocked=true