1

我在 Jenkins 中有以下错误(指的是磁盘上的路径,下面的每个实例都可以不同,并且不一定与所有其他实例相同)

The command "tsc "C:\<path>\shared.editpage-default.ts" "C:\<path>\shared.editpage-editenabled.ts" "C:\<path>\shared.filters.ts" "C:\<path>\perfect.common.interfaces.d.ts" "C:\<path>\perfect.hide-and-seek.ts" "C:\<path>\perfect.domutils.ts" "C:\<path>\jquery.validation.d.ts" "C:\<path>\perfect.pagination.ts" "C:\<path>\perfect.sorting.ts" "C:\<path>\jquery.d.ts" "C:\<path>\perfect.langchange.ts" "C:\<path>\perfect.switchbox.ts" "C:\<path>\perfect.validation.ts"" exited with code 9009.
c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(847,9): warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [C:\<path>\<proj>.csproj]

现在,问题是这样的。我们的项目文件中有一个部分用于构建我们的 TypeScript 文件并在每次保存 TypeScript 文件时创建 .js 文件。这是部分:

  <Target Name="BeforeBuild">
    <Message Text="Compiling TypeScript files" />
    <Message Text="Executing tsc$(TypeScriptSourceMap) @(TypeScriptCompile ->'&quot;%(fullpath)&quot;', ' ')" />
    <Exec Command="tsc$(TypeScriptSourceMap) @(TypeScriptCompile ->'&quot;%(fullpath)&quot;', ' ')" IgnoreExitCode="true" />
  </Target>

这一切在本地都很好,但在 Jenkins 中失败了,因为 Jenkins 服务器没有安装 TypeScript。问题是我实际上不需要在 Jenkins 上执行 TypeScript 命令,因为正如我所说,生成的 .js 文件无论如何都是在保存时构建和创建的,我们将它们签入。所以有三个选项。

  1. 在构建服务器上安装 TypeSctipt。
  2. 更改项目文件中的命令,使其仅执行<Exec Command="tsc ...如果我们在配置中是 Debug。
  3. 将我的构建脚本更改为不构建 TypeScript 文件。

这是我尝试过的。

  1. 我想我会尝试在构建服务器上安装 TypeScript,但该服务器是一台旧的 Windows Server 2003 机器,当我尝试在其上安装 TypeScript 0.8.3 时出现以下错误。因此,我在机器上安装了最新的 Windows 更新并重新启动并重新运行 TypeScript 安装并得到相同的错误。

在此处输入图像描述

至于选项 2 和 3。

我认为 2 将是最简单的一个,尽管我只是不知道我必须使用的 if 语句仅用于为 Debug 配置构建。如果这是解决方案,请让我知道命令。

选项 3 我认为可能相当困难。

请提出一些建议。

4

1 回答 1

1

选项 2 应该很容易实现。Exec 任务 ( http://msdn.microsoft.com/en-us/library/x8zx72cd.aspx ) 支持 Condition 参数 ( http://msdn.microsoft.com/en-us/library/7szfhaft.aspx )。我认为你想要的看起来像这样:

<Exec Command="..." Condition="'$(Configuration)' == 'Debug'" />
于 2013-03-12T21:14:53.113 回答