Sunday, June 3, 2012

Copy Local Property of a Reference

The Copy Local property of the reference is tricky. I was expecting once i set this property to true it will automatically copy all the related dlls to the build path. But unfortunately this is not the case. All the assemlies are not copied.

From  MSDN (http://msdn.microsoft.com/en-us/library/ez524kew%28VS.80%29.aspx)
At run time, components must be either in the output path of the project or in the Global Assembly Cache (GAC). If the project contains a reference to an object that is not in one of these locations, you must copy the reference to the output path of the project when you build the project. The CopyLocal property indicates whether this copy needs to be made. If the value is True, the reference is copied to the project directory when you build the project. If False, the reference is not copied.

If you deploy an application that contains a reference to a custom component that is registered in the GAC, the component will not be deployed with the application, regardless of the CopyLocal setting. In previous versions of Visual Studio, you could set the CopyLocal property on a reference to ensure that the assembly was deployed. Now, you must manually add the assembly to the \Bin folder. This puts all custom code under scrutiny, reducing the risk of publishing custom code with which you are not familiar.
By default, the CopyLocal property is set to False if the assembly or component is in the global assembly cache or is a framework component. Otherwise, the value is set to True. Project-to-project references are always set to True.

No comments:

Post a Comment