0

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" />

cdub
  • 24,555
  • 57
  • 174
  • 303

1 Answers1

1

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. enter image description here

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:

... under the covers they all use msbuild's ResolveAssemblyReference task. If a dependency is in the gac, no matter where we resolve it from, we will set copy local to false. This is part of a heuristic we apply to try and determine if the assembly should be copy local or not. We are assuming that because it was installed in the gac that it will also be in the gac of any target machines and therefore copy local is not required.

Jay Walker
  • 4,654
  • 5
  • 47
  • 53
  • ohh so i need to have it installed on the machine doing the msbuild? – cdub Nov 20 '12 at 03:32
  • i have it installed locally on my machine but not on the continuous integration server with the msbuild – cdub Nov 20 '12 at 03:34
  • Not sure exactly which condition applies. Can you post the specific build error? – Jay Walker Nov 20 '12 at 03:35
  • Can you add a project relative hintpath to the Extreme Reference (i'm just guessing at a path below)? SQLCLR ..\lib\Extreme.Numerics.dll True – Jay Walker Nov 20 '12 at 03:53
  • so every time i change soemthing and the csproj changes i will have to add that back in? – cdub Nov 20 '12 at 03:58
  • You should be able to add a folder to your SQL CLR project. Add the Extreme assembly to that folder, then add/update an assembly reference to Extreme to point to that folder. Open the csproj file in a text editor to verify the hint path is there and that it is a relative reference off the solution root. Once you set the hintpath, you shouldn't have to update it when you make other changes to the csproj. – Jay Walker Nov 20 '12 at 04:05
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/19794/discussion-between-jay-walker-and-chris) – Jay Walker Nov 20 '12 at 04:20
  • yes but how do you update the assembly reference to point to that folder – cdub Nov 20 '12 at 07:23
  • okay I gave you the answer. It was the GAC. Only the assembly gets removed from the GAC on my local, it does a copy and works on the test msbuild server. – cdub Nov 20 '12 at 08:18