Do NOT Change "Copy Local” project references to false, unless understand subsequences.
Posted
by Michael Freidgeim
on Geeks with Blogs
See other posts from Geeks with Blogs
or by Michael Freidgeim
Published on Sun, 09 Dec 2012 12:15:36 GMT
Indexed on
2012/12/09
5:05 UTC
Read the original article
Hit count: 653
- e.g. From http://stackoverflow.com/questions/690033/best-practices-for-large-solutions-in-visual-studio-2008
- CopyLocal? For sure turn this off
- Always set the Copy Local property to false and enforce this via a custom msbuild step
- My advice is to always set ‘Copy Local’ to false
Some time ago we've tried to change the setting to false, and found that it causes problem for deployment of top-level projects.
Recently I've followed the suggestion and changed the settings for middle-level projects. It didn't cause immediate issues, but I was warned by Readify Consultant Colin Savage about possible errors during deployments
I haven't undone the changes immediately and we found a few issues during testing.
There are many scenarios, when you need to have Copy Local’ left to True.
Second-level dependencies: set copy local = true.If you set ‘ Copy Local = false’, VS will, unless you tell it otherwise, place each assembly alone in its own .\bin\Debugdirectory. Because of this, you will need to configure VS to place assemblies together in the same directory. To do so, for each VS project, go to VS > Project Properties > Build tab > Output path, and set the Ouput path to ..\bin\Debugfor debug configuration, and ..\bin\Release for release configuration.
Another example when copylocal =false fails on run-time, is when top level assembly doesn't directly referenced one of indirect dependencies.
E..g. Top-level assembly A has reference to assembly B with
and http://stackoverflow.com/questions/602765/when-should-copy-local-be-set-to-true-and-when-should-it-not?lq=1Copy local is important for deployment scenarios and tools. As a general rule you should use CopyLocal=True
Unfortunately there are some quirks and CopyLocal won't necessary work as expected for assembly references in secondary assemblies structured as shown below.
- MainApp.exe
- MyLibrary.dll
- ThirdPartyLibrary.dll (if in the GAC CopyLocal won't copy to MainApp bin folder)
This makes xcopy deployments difficult .
.
The fix for the issue is recommended in http://stackoverflow.com/a/6200173/52277
"I solved this issue by setting the Copy Local attribute of my project's references to true."
© Geeks with Blogs or respective owner