문제

I am trying to get typescript to run on appharbor using the typescript html5 project template.

I have copied the Typescript target folder from the MSBuild folder and the SDK folder into my project, locally everything works however when I push to appharbor I get the error detailed below.

I also took the liberty to amend the typescript target from looking for the SDK in the Microsoft SDk folder to look at my "vendors" folder instead.

The typescript compiler's version is 0.9.1.1

The error message I get the following one:

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

I get the following typescript task output on my build.

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

Below you can see the error.

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]

I have created a public gist with the full build output.

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

I also created a gist for the typescript target so you can see the changes I made to it.

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

Thx and advance

UPDATE

As Ryan suggested I have changed from the tsc.exe to running the tsc.js file with nodejs I had to add the Typescript SDK and the Nodejs binaries to my GIT repository (which is good practice anyway) and finally add the required exec task to the typescript project file.

List of things you need to do.

  1. Add Nodejs to your repository
  2. Add Typescript Sdk to your repository
  3. Remove the import for typescript targets from your project
  4. Add the exec task to execute tsc.js using nodejs

See below the MSBuild xml I am using on my project.

  <!-- 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>
도움이 되었습니까?

해결책

TypeScript 0.9.1.1 requires IE10 or later to be installed. If that's not an option for you, you can run tsc.js through node instead.

다른 팁

The solution that dmportella has included in his answer worked for me also, however the MSBuild target didn't want to work just by copying and changing the paths.

Here is the target that worked for me (please discard the path changes, that's not the important part):

<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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top