I am tying to do msbuild (continuous integration) for a SQL CLR project in VS 2010/SQL Server 2005. The project builds correctly in VS, but I can’t get it to build in msbuild since it needs a 3rd party external reference.
The typical way to get around this is to add a Library folder and point the reference to that library folder. How do I do that in a SQL CLR project?
The build errors I get are:
[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.
The itemgroup in the build project file is:
<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" />
You should be able to add assembly references to your SQL CLR project using the Add Reference feature. Then set the Reference Properties – Copy Local to true.

but… if that doesn’t work the issue might be with what is installed in your local GAC vs. what is installed in the GAC where you are running your CI build because of the way MSBuild resolves assembly references.
Chris Mann (MSFT) says more about GAC refs here: