When should copy-local be set to true and when should it not?
I am wondering if there are any heuristics for when to set copy-local=true
for references?
If referenced types are only used internally can I set copy-local
to true
but if referenced types are exposed as parameters or return values I set copy-local
to false
and indicate that a specific version of the dependency should be referenced when my library should be used?
Can anyone clarify this for me?
Copy local is important for deployment scenarios and tools. As a general rule you should use CopyLocal=True if the reference is not contained within the GAC.
Copy Local essentially means I must manually deploy this DLL in order for my application to work. When it's false it essentially means "I depend on another component which must be installed separately or chained, the DLL will just be there already".
Copy local was implemented really to support local debugging. When you perpare your application for package and deployment you should build your projects to the same output folder and make sure you have all the references you need there.
CopyLocal is especially a pain when building large source trees. There was a related question about how to disable CopyLocal here on SO you can see it at How do I override CopyLocal (Private) setting for references in .NET from MSBUILD. As well as Best practices for large solutions in Visual Studio (2008).
I have written about how to deal with building large source trees in the article MSBuild: Best Practices For Creating Reliable Builds, Part 2.
So in short I would say disable CopyLocal when the file copying is causing your builds to take more time then you are willing to spend for every build.