【问题标题】:Typescript compilation issues in AppharborAppharbor 中的打字稿编译问题
【发布时间】:2013-09-06 21:56:37
【问题描述】:

我正在尝试使用 typescript html5 项目模板让 typescript 在 appharbor 上运行。

我已将 Typescript 目标文件夹从 MSBuild 文件夹和 SDK 文件夹复制到我的项目中,在本地一切正常,但是当我推送到 appharbor 时,我收到下面详细说明的错误。

我还冒昧地修改了 typescript 目标,从在 Microsoft SDk 文件夹中查找 SDK 改为查看我的“供应商”文件夹。

打字稿编译器的版本是0.9.1.1

我收到以下错误消息:

error MSB6006: "tsc.exe" exited with code 1

我在构建中得到以下打字稿任务输出。

CompileTypeScript:
D:\temp\bn4vn5tf.fls\input\test\..\Vendors\TypeScript\tsc.exe  --removeComments --declaration --module AMD --out ".\js\all.js" --target ES5 "app.ts"

您可以在下面看到错误。

CompileTypeScript:
Cannot initialize ActiveScript
D:\temp\bn4vn5tf.fls\input\vendors\TypeScript\Microsoft.TypeScript.targets(72,5): error MSB6006: "tsc.exe" exited with code 1. [D:\temp\bn4vn5tf.fls\input\test\test.csproj]

我创建了一个包含完整构建输出的公共要点。

https://gist.github.com/dmportella/6470465

我还为 typescript 目标创建了一个要点,以便您可以看到我对其所做的更改。

https://gist.github.com/anonymous/6470504

谢谢并提前

更新

正如 Ryan 建议的那样,我已从 tsc.exe 更改为使用 nodejs 运行 tsc.js 文件,我必须将 Typescript SDK 和 Nodejs 二进制文件添加到我的 GIT 存储库(无论如何这是一个好习惯),最后添加所需的执行任务到 typescript 项目文件。

你需要做的事情的清单。

  1. 将 Nodejs 添加到您的存储库
  2. 将 Typescript Sdk 添加到您的存储库中
  3. 从您的项目中删除 typescript 目标的导入
  4. 添加exec任务以使用nodejs执行tsc.js

请参阅下面我在项目中使用的 MSBuild xml。

  <!-- Target ignored as it will not work on appharbor -->
  <!--<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />-->
  <Target Name="BuildTypeScript" BeforeTargets="build">
    <Message Importance="high" Text="Running TypeScript Compiler using NodeJs" />
    <Message Importance="high" Text="..\Vendors\nodejs\node.exe ..\Vendors\TypeScript\tsc.js --removeComments --declaration --module AMD --out $(TypeScriptOutFile) --target ES5 @(TypeScriptCompile)"/>
    <Exec Command="..\Vendors\nodejs\node.exe ..\Vendors\TypeScript\tsc.js --removeComments --declaration --module AMD --out $(TypeScriptOutFile) --target ES5 @(TypeScriptCompile)"/>
  </Target>

【问题讨论】:

    标签: .net compilation msbuild typescript appharbor


    【解决方案1】:

    TypeScript 0.9.1.1 需要安装 IE10 或更高版本。如果这不适合您,您可以改为通过节点运行 tsc.js。

    【讨论】:

    • 好吧有道理有没有办法改变目标来调用nodejs.exe而不是tsc.exe?
    • 我找到了这个链接weekly-training.blogspot.co.uk/2012/10/… 好像在0.8.0.0版本可以运行,我稍后再试试
    • 只是tsc.exe需要ie10的vs任务不起作用?
    • 谢谢瑞恩。如果您能够帮助解决上述问题,那就太好了,否则我将发布另一个问题
    • 我已经用我粗略的 msbuild 脚本更新了我的问题,以使用 nodejs 在 apphrbor 中构建 ts 脚本。
    【解决方案2】:

    dmportella 在他的回答中包含的解决方案也对我有用,但是 MSBuild 目标不想仅仅通过复制和更改路径来工作。

    这是对我有用的目标(请丢弃路径更改,这不是重要部分):

    <Target Name="BuildTypeScript" BeforeTargets="build" Outputs="%(TypeScriptCompile.Identity)">
      <Message Importance="high" Text="Running TypeScript Compiler using NodeJs" />
      <Message Importance="high" Text="..\..\Tools\nodejs\node.exe ..\..\Tools\typescript\sdk\tsc.js --removeComments --declaration --module AMD --target ES5 %(TypeScriptCompile.Identity)"/>
      <Exec Command="..\..\Tools\nodejs\node.exe ..\..\Tools\typescript\sdk\tsc.js --removeComments --declaration --module AMD --target ES5 %(TypeScriptCompile.Identity)"/>
    </Target>
    

    【讨论】:

      猜你喜欢
      • 2015-12-17
      • 1970-01-01
      • 1970-01-01
      • 2018-12-23
      • 2013-08-19
      • 1970-01-01
      • 1970-01-01
      • 2020-04-07
      相关资源
      最近更新 更多