在我使用的解决方案中,有一个项目大量使用 typescript ,我试图让这个项目通过构建,以便在其上运行 msbuild..
已尝试编辑 .csproj
使用 typescript 的项目文件并向其添加属性 <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
下<PropertyGroup>
元素,但这没有帮助。
也试过:<TypeScriptEnabled>false</TypeScriptEnabled>
这也没有帮助。
如何设置 VS2015 忽略 typescript
以及我可以向“msbuild”命令添加什么以使其忽略 typescript
还有吗?
最佳答案
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'.
注: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 项目构建输出详细程度更改为详细信息,然后检查输出窗口中的日志:
我想提供另一种方法来抑制 typescript 错误:
选择 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
关于asp.net - VS 2015 和 msbuild 抑制 typescript 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46037063/