Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 832
Fadeproof Avatar asked Mar 02 '09 15:03

Fadeproof


People also ask

What does Copy Local do?

The CopyLocal property indicates whether this copy needs to be made. If the value is true , the reference is copied to the output path of the project at run time. If false , the reference is not copied.


2 Answers

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

like image 136
JaredPar Avatar answered Sep 18 '22 16:09

JaredPar


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.

like image 42
Sayed Ibrahim Hashimi Avatar answered Sep 20 '22 16:09

Sayed Ibrahim Hashimi