0

我正在为 VS 2010/SQL Server 2005 中的 SQL CLR 项目执行 msbuild(持续集成)。该项目在 VS 中正确构建,但我无法在 msbuild 中构建它,因为它需要第 3 方外部参考。

解决此问题的典型方法是添加一个库文件夹并将引用指向该库文件夹。我如何在 SQL CLR 项目中做到这一点?

我得到的构建错误是:

[19:38:42]CorrSqlServerCompo\PowerStatRegression.csproj.teamcity: Build target: Build
[19:38:42][CorrSqlServerCompo\PowerStatRegression.csproj.teamcity] CoreCompile
[19:38:42][CoreCompile] Csc
[19:38:42][Csc] matrix\MatrixHandler.cs(5, 7): error CS0246: The type or namespace name 'Extreme' could not be found (are you missing a using directive or an assembly reference?)
[19:38:42][Csc] matrix\MatrixHandler.cs(6, 7): error CS0246: The type or namespace name 'Extreme' could not be found (are you missing a using directive or an assembly reference?)
[19:38:42][Csc] matrix\MatrixHandler.cs(216, 51): error CS0246: The type or namespace name 'GeneralMatrix' could not be found (are you missing a using directive or an assembly reference?)
[19:38:42][CorrSqlServerCompo\PowerStatRegression.csproj.teamcity] Project CorrSqlServerCompo\PowerStatRegression.csproj.teamcity failed.

构建项目文件中的 itemgroup 为:

<ItemGroup>
<Reference Include="Extreme.Numerics.Net20, Version=3.6.10055.0, Culture=neutral, PublicKeyToken=9e513770f58567b2, processorArchitecture=MSIL">
  <SubType>SQLCLR</SubType>
  <Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.XML" />

4

1 回答 1

1

您应该能够使用添加引用功能将程序集引用添加到您的 SQL CLR 项目。然后将 Reference Properties - Copy Local 设置为 true。 在此处输入图像描述

但是...如果这不起作用,则问题可能在于本地 GAC 中安装的内容与运行 CI 构建的 GAC 中安装的内容,因为 MSBuild 解析程序集引用的方式。

Chris Mann (MSFT)在这里详细介绍了 GAC 裁判:

...在幕后,他们都使用 msbuild 的 ResolveAssemblyReference 任务。如果 gac 中有依赖项,无论我们从哪里解析它,我们都会将 copy local 设置为 false。这是我们用来尝试确定程序集是否应该复制本地的启发式方法的一部分。我们假设因为它安装在 gac 中,所以它也将在任何目标机器的 gac 中,因此不需要复制本地。

于 2012-11-20T03:31:10.257 回答