MSBuild一个具有外部依赖关系的SQL CLR项目

时间:2012-11-20 01:39:30

标签: .net visual-studio-2010 exception-handling msbuild sqlclr

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

解决此问题的典型方法是添加Library文件夹并将引用指向该库文件夹。我如何在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>
<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" />

1 个答案:

答案 0 :(得分:1)

您应该能够使用“添加引用”功能向SQL CLR项目添加程序集引用。然后将Reference Properties - Copy Local设置为true。 enter image description here

但是......如果这不起作用,问题可能出在本地GAC中安装的内容与运行CI构建的GAC中安装的内容之间的问题,因为MSBuild解析了程序集引用。< / p>

Chris Mann(MSFT)详细介绍了GAC引用here

  

......他们都使用msbuild的ResolveAssemblyReference任务。如果依赖关系在gac中,无论我们从何处解决它,我们都将copy local设置为false。这是我们申请尝试确定程序集是否应该复制到本地的启发式的一部分。我们假设因为它安装在gac中它也将在任何目标机器的gac中,因此不需要复制本地。

相关问题