【问题标题】:Typescript build error (TS5007)打字稿构建错误(TS5007)
【发布时间】:2014-10-05 18:05:59
【问题描述】:

我一直在尝试通过 visualstudio.com 上的构建服务器构建 typescript,并且我已经完成了将 typescript 引入源代码控制的正常工作。但是我遇到了以下问题:

VSSTC:错误 TS5007:构建: 无法解析引用的文件: 'COMPUTE_PATHS_ONLY'。 [C:\a\src\Main\RecruitCloud\RecruitCloud.csproj]

我知道编码问题,但在我看到的所有示例中,罪魁祸首文件已在错误消息中命名。

我开始认为这可能取决于我在项目中编译的打字稿文件的数量。

有什么想法吗?

【问题讨论】:

标签: msbuild typescript


【解决方案1】:

这是运行编译器的 VsTsc 任务的配置选项。它用于PreComputeCompileTypeScript 目标。目的是让 VsTsc 任务完成所有动作,except 以运行编译器。这并没有在你的机器上成功,它实际上确实运行了编译器。然后由于找不到名为 COMPUTE_PATHS_ONLY 的文件而引发了麻烦。

VsTsc 任务存储在 C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\TypeScript\TypeScript.Tasks.dll 中。用反编译器查看程序集:

protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands)
{
    if (this.Configurations.Contains("--sourcemap"))
    {
        this.generateSourceMaps = true;
    }
    else
    {
        this.generateSourceMaps = false;
    }
    if (this.Configurations.Contains("--declaration"))
    {
        this.generateDeclarations = true;
    }
    else
    {
        this.generateDeclarations = false;
    }
    this.GenerateOutputPaths();
    if (!responseFileCommands.Contains("COMPUTE_PATHS_ONLY"))
    {
        return base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands);
    }
    return 0;
}

注意 !responseFileCommands.Contains() 测试绕过 base.ExecuteTool() 调用。

我只能猜测该方法在您的机器上看起来不像这样。最可能的原因是您的 TypeScript.Tasks.dll 版本过时。在我安装了 VS2013 Update 4 的机器上,日期为 2014 年 11 月 11 日,大小为 27816 字节。

【讨论】:

  • 我反编译了我的TypeScript.Tasks.dll,它与你的匹配。我对 Visual Studio 进行了完整的修复安装,问题仍然存在。我有点困惑,因为症状表明你是对的。
  • 无赖,还以为是灌篮高手的解释。我需要查看详细的 msbuild 跟踪才能提出另一个理论。
  • 详细显示它正在加载 v11/TypeScript.Task.dll Target "PreComputeCompileTypeScript" in file "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\TypeScript\Microsoft.TypeScript.targets" from project "C:\Users\jayt\Documents\Visual Studio 2013\Projects\taglich.fix\AdminMVC\AdminMVC.csproj" (target "CompileTypeScript" depends on it): Using "VsTsc" task from assembly "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\TypeScript\TypeScript.tasks.dll". 我仍然需要弄清楚原因。
  • 我正在使用 vs2012,我得到同样的错误“构建:无法解析引用文件:'COMPUTE_PATHS_ONLY'”,我反编译了 dll,我发现我错过了 !responseFileCommands.Contains("COMPUTE_PATHS_ONLY" ) 是否有任何版本的用于 vs2012 的此 dll 具有此验证,我可以在哪里下载?
【解决方案2】:

最好的办法是简单地以 Unicode 编码重新保存所有文件。您可以通过一个快速的 powershell 脚本 (Change files' encoding recursively on Windows?)

Get-ChildItem *.txt | ForEach-Object {
$content = $_ | Get-Content

Set-Content -PassThru $_.Fullname $content -Encoding UTF8 -Force}

【讨论】:

    猜你喜欢
    • 2016-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多