Can I set the default-option of "Copy Local" in Visual Studio to False? In most times, when I add a dll as dependency of a project, I want the Copy Local property set to False. Per default, it is True. Is there a way to change the default behaviour of Visual Studio? (2008)
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".
No - Visual Studio uses an internal set of rules to determine what to set Copy Local to.
From MSDN:
- If the reference is another project, called a project-to-project reference, then the value is true.
- If the assembly is found in the global assembly cache, the value is false.
- As a special case, the value for the mscorlib.dll reference is false.
- If the assembly is found in the Framework SDK folder, then the value is false.
- Otherwise, the value is true.
Actually, you can. You need a couple things:
.targets
file that makes copylocal (<Private>
tag, to be precise) false by default..csproj
files. You can add it in the very last line, before closing </Project>
tag, it'll look like <Import Project="..\Build\yourtarget.targets" />
.Now each project with this target has copylocal disabled by default.
The drawback is that you need to modify each and every csproj file, including new ones. You can work around the new project issue by modifying the VS project template. Instead of Class.cs
described in the blog article, you need to modify Class.vstemplate
(in the same zip file).
With that approach, there's one more problem - the path itself. If you use hardcoded relative path in newly-generated csproj files, they may be wrong (unless you have flat project structure).
You can:
There must be better solution for that, but haven't found it yet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With