Appharbor中的打字稿编译问题

时间:2013-09-06 21:56:37

标签: .net compilation msbuild typescript appharbor

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

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

我还冒昧地修改了typescript目标,从查找Microsoft SDk文件夹中的SDK来查看我的“vendors”文件夹。

打字稿编译器的版本为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

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

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

Thx并提前

更新

由于Ryan建议我已经从tsc.exe更改为使用nodejs运行tsc.js文件,我必须将Typescript SDK和Nodejs二进制文件添加到我的GIT存储库(这无论如何都是好的做法),最后添加所需的exec任务到打字稿项目文件。

您需要做的事情清单。

  1. 将Nodejs添加到您的存储库
  2. 将Typescript Sdk添加到您的存储库
  3. 从项目中删除打字稿目标的导入
  4. 使用nodejs
  5. 添加exec任务以执行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>
    

2 个答案:

答案 0 :(得分:5)

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

答案 1 :(得分:5)

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>