When working on a VS 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. (Thanks to SO, I know how to prevent this from happening, but I still want to find out why it happens in the first place.)
4 Answers
I believe this happens because Microsoft.SharePoint.dll
uses it as a dependency. As Microsoft.SharePoint.Search.dll
is not in the GAC, Visual Studio copies it to the bin folder.
-
OK so I just read the SO answers which say essentially the same thing. What is it that you're not clear on? Oct 8, 2009 at 19:58
-
Hmmm.. Microsoft.SharePoint.dll references a lot of other non-GAC assemblies (Microsoft.SharePoint.Security for example) but those don't get copied. Perhaps it is dragged in because a concrete constructor somewhere calls or can call something in the search.dll?– HafthorOct 8, 2009 at 20:33
-
I just found it really odd because I've never seen this behavior any other time.– HafthorOct 8, 2009 at 20:34
-
Have you checked if the other assemblies it references are already in the GAC? Oct 8, 2009 at 20:59
Alex is correct, if you want to stop this happening you can use this hack:
- Add a reference to
Microsoft.SharePoint.Search.dll
(in the 12\ISAPI directory) - Select and in the Properties page set Copy Local = false
This makes it easier when you want to do post build events like coping DLL around.
-
Apologies - just saw the link to SO to explain how to stop this. I suppose it's useful here though as we build up our SPO (is that the right acronym?) Oct 9, 2009 at 10:54
If it works for you, try putting a build event in your project. Right click the project in Solution Explorer, click Properties, and then go to the Build tab. In Post Build events, put the text:
cd $(ProjectDir) del bin\Microsoft.SharePoint.Search.dll del bin\Microsoft.SharePoint.Search.xml
This will delete the files after every build.
One of our customers experienced this problem and it appeared to be due to the Office Developers Tools for Visual Studio option available at the Individual Components section of the Visual Studio 2019 installation wizard, e.g.
The solution is to uncheck it and to uninstall the addon. Therefore, the SharePoint related assemblies should not be added to the project when compiling it.