visual studio copy local

2019-01-17 23:28发布

问题:

In visual studio, when you add a reference there is a flag in the properties called, "Copy Local". There is some confusion about what this actually does and when. It seems easy to understand but my question is when does it copy local. Is it when the reference is added or does it copy the dll locally when the project is built.

The reason for this question is we have created a asp.net template file that refences a dll that is on all of our devs local workstations in exactly the same place. We thought that by setting the flag to "Copy Local", this would reference the location where the dll lives but when we use the template, the reference is broken and needs to be re-added.

Can anyone shed some light on this?

回答1:

The Copy Local property determines whether a reference is copied to the local bin path. At run time, a reference must exist in either the Global Assembly Cache (GAC) or the output path of the project. If this property is set to true, the reference is copied to the output path of the project at run time.

So this property is actually not useful in your scenario.

I'm unable to suggest a better solution than adding the assembly to the GAC in each developer workstation: http://msdn.microsoft.com/en-us/library/yf1d93sz.aspx