【问题标题】:Disable typescript compilation in Visual Studio 2013在 Visual Studio 2013 中禁用打字稿编译
【发布时间】:2016-04-01 01:41:43
【问题描述】:

我正在运行 grunt 并设置了一个 typescript 构建过程来监听文件更改,因此当我保存或构建我的项目时,我不需要我的 typescript 文件的默认 VS 编译。

我已取消选中项目属性中 typescript 下的“保存时编译”选项,但 ts 文件仍在编译中。这对我有用的唯一方法是如果我将单个 TS 文件的构建操作设置为“无”,但这仍然会导致一些 Typescript 文件被编译。 VS2013有什么办法可以做到吗?

【问题讨论】:

  • 您有解决方案吗?目前遇到同样的问题。
  • 嗨 xvdiff。如上所述,在我的项目属性中取消选中 typescript 下的“保存时编译”选项,然后将 ts 文件的构建操作设置为“无”。我知道有点乏味,但这是我让它工作的唯一方法。
  • 确保您没有可在构建时编译的 Web Essentials 或类似扩展。

标签: visual-studio-2013 gruntjs


【解决方案1】:

在 VS2015 中,<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> 设置可以添加到 .csproj 中的第一个 <PropertyGroup> 元素

msbuild 输出应该会显示

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

发件人:http://rostacik.net/2015/08/14/how-to-disable-building-of-typescript-files-in-visual-studio-2015/

【讨论】:

  • 对于我的 VS2015 asp.net core RC2 项目(没有 .csproj 文件),将 true 添加到 .xproj(不是 .csproj)文件中会停止打字稿当我发布我的项目时发生的编译。 Typescript 在开发过程中已经没有在保存时编译,因为我在我的项目中添加了一个 tsconfig.json(没有“compileOnSave”:true)。我使用 gulp 为我的工作流程进行编译。但在我的情况下, true 需要在我的项目发布期间禁止编译。我正在使用 Typescript 1.8.9。
【解决方案2】:

我有同样的问题和解决方案,我发现是在 VS 项目文件中覆盖 TypeScript 目标:

<Target Name="PreComputeCompileTypeScript">
  <Message Text="Skipping PreComputeCompileTypeScript" />
</Target>
<Target Name="CompileTypeScript">
  <Message Text="Skipping CompileTypeScript" />
</Target>
<Target Name="GetTypeScriptCopyToOutputDirectoryItems">
  <Message Text="Skipping GetTypeScriptCopyToOutputDirectoryItems" />
</Target>

【讨论】:

    【解决方案3】:

    @Christopher Mott 的回答也适用于 Visual Studio 2013,至少适用于 Update 5TypeScript Tools for Microsoft Visual Studio 2013 1.8.5.0。可以肯定的是,可以验证 VS TypeScript 工具链是否理解该标志:

    为预期项目打开 .csproj 文件,并注意它从一些导入 TypeScript 目标:

    $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets

    通常映射到:

    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\\TypeScript\Microsoft.TypeScript.targets

    检查该文件并查找在某些&lt;PropertyGroup&gt; 中定义的TypeScriptCompileBlocked(为假)。如果它在那里,你就被分类了。返回 .csproj 文件并在导入 TypeScript 目标之后添加以下内容:

    <!-- Disable TypeScript compilation from within VS, leave that to external tools -->
    <PropertyGroup>
      <TypeScriptCompileBlocked>True</TypeScriptCompileBlocked>
    </PropertyGroup>
    

    【讨论】:

      【解决方案4】:

      将 TypeScript 文件上的 Build Action 属性更改为 TypeScript Compile 以外的其他值

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-06-12
        • 1970-01-01
        • 2023-03-24
        • 1970-01-01
        • 2013-12-30
        • 1970-01-01
        相关资源
        最近更新 更多