views:

1393

answers:

6

When working on a VS2005 project that involves referencing Microsoft.SharePoint.dll, building the project causes Microsoft.SharePoint.Search.dll to be copied to my bin folder. Why is this? Okay, maybe it's just a bug, but I want to know the mechanism.

[Edit: Copy local is most definitely turned off -- Microsoft.SharePoint.dll is not copied. Microsoft.SharePoint.Search.dll is not in the GAC but it wouldn't matter if it was.]

A: 

Did you try turning off 'Copy Local' in the properties for the reference to Microsoft.SharePoint.dll ?

Kev
A: 

may be because it is not in GAC, because other files which are in GAC are not copied there.

TheVillageIdiot
A: 

Its probably a dependency, and you have copy local enabled.

I'd keep copy local enabled though, as it really eases deployment pains.

FlySwat
I don't agree that copy local is a good move for MS assemblies. What if a hotfix has been deployed to the server and your solution is referencing (and copying) an unpatched version? Mayhem!
Alex Angas
+2  A: 
  • It's not in the GAC
  • It's being used by one of the Assemblies you reference (i think Microsoft.Sharepoint.dll references it)
  • Since you don't reference it, you cannot set Local Copy to FALSE as far as I know
  • I've changed my build/deployment scripts to just delete it.
Michael Stum
That's strange that you got down voted when your answer is the closest to what's happening. I've upvoted it but I want to understand why this happens. It can't just be the referenced referencing causing the copy... this hasn't happened elsewhere AFAIK.
Hafthor
+1  A: 

What worked for me is to

  • add reference to Microsoft.SharePoint and Microsoft.SharePoint.Search (even if you don't need it)
  • set Copy Local to false for both references.

When you build the project none of them gets copied to debug/release/whatever directory.

galbitz
no kidding? I'll check that out and accept if it works. Thx.
Hafthor
sorry that took so long - it does work - accepting, although I'd still like to know why this is happening. Shrug.
Hafthor
A: 

If you machine (host) where you are compiling an assembly that is a x64 architecture and you have the x64 version of SharePoint installed (with the references set to those assemblies) during "add reference" it will set Copy local to false.

So, if the assembly is AMD64 and you have "Any CPU" set, then the "add reference" set's the copy local = true, regardless. If you change it to false, but you then reference this project from another that also has it's target set to Any CPU or NOT x64, then the reference get's copied through as well.

Take a look a custominzing the MSBuild as needed in this link: http://stackoverflow.com/questions/1682096/how-do-i-override-copylocal-private-setting-for-references-in-net-from-msbuild

Cicorias