一次编译许多打字稿文件导致文件找不到错误 [英] Compiling many typescript files at once resulted in File not found error

查看:67
本文介绍了一次编译许多打字稿文件导致文件找不到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个MSBuild脚本,可用于编译项目中的所有.ts文件.首先,我们创建一个包含所有.ts文件的属性组;

We have an MSBuild script which we use to compile all our .ts files in our project. First we create a propery group containing all the .ts files;

<ItemGroup>
   <AllTypeScriptFiles Include="XXXXX\Scripts\**\*.ts;" Exclude="XXXX\Scripts\**\*.d.ts;" /> 
</ItemGroup>

然后我们将此文件列表转储到输入文件中并运行tsc.exe;

Then we dump this file list to an input file and run tsc.exe;

<WriteLinesToFile
    File="typescriptcompiler.input"
    Lines="@(AllTypeScriptFiles)"
    Overwrite="true"
    Encoding="Unicode"/>    

<Exec Command="&quot;$(MSBuildProgramFiles32)\Microsoft SDKs\TypeScript\$(TypeScriptVersion)\tsc&quot; --target ES5 @typescriptcompiler.input"
      CustomErrorRegularExpression="\.ts\([0-9]+,[0-9]+\):(.*)"
      IgnoreExitCode="true" >
</Exec>

现在,输出显示找不到某些文件;

Now, the output states that some files can not be found;

Error reading file "XXXXX.ts": File not found

某些文件会发生这种情况,但是如果我运行tsc.exe并给出与错误消息完全相同的路径,则不会出现任何错误,并且文件已编译.

This happens to some files, but if I run tsc.exe giving the exact same path as the error message I get no errors and the file is compiled.

如果我宁愿按顺序编译每个文件,则:

If I rather compile each file in sequence instead:

<Exec Command="&quot;$(MSBuildProgramFiles32)\Microsoft SDKs\TypeScript\$(TypeScriptVersion)\tsc&quot; --target ES5 &quot;%(AllTypeScriptFiles.Identity)&quot;"
      CustomErrorRegularExpression="\.ts\([0-9]+,[0-9]+\):(.*)"
      IgnoreExitCode="true" >
</Exec>

所有文件的编译都没有问题,只需要5分钟而不是10秒...

All files are compiled without problems, except it takes 5 minutes instead of 10 seconds...

推荐答案

Typescript version 0.8.3 solves this problem! No more erros.

我现在可以一次编译所有文件:

I am now able to compile all the files with one go:

<ItemGroup>
   <AllTypeScriptFiles Include="XXXXX\Scripts\**\*.ts;" Exclude="XXXX\Scripts\**\*.d.ts;" /> 
</ItemGroup>

<WriteLinesToFile
    File="typescriptcompiler.input"
    Lines="@(AllTypeScriptFiles)"
    Overwrite="true"
    Encoding="Unicode"/>    

<Exec Command="&quot;$(MSBuildProgramFiles32)\Microsoft SDKs\TypeScript\$(TypeScriptVersion)\tsc&quot; --target ES5 @typescriptcompiler.input"
      CustomErrorRegularExpression="\.ts\([0-9]+,[0-9]+\):(.*)">
</Exec>

这篇关于一次编译许多打字稿文件导致文件找不到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆