Visual Studio, MSBuild, Copy Local, Private

I have faced a problem with the CI server. Actually the problem was with MSBuild.  Which is used to build assemblies at the server. The project has all referenced assemblies set to “Copy Local” True.  Thus we are sure all required assemblies could be accessible by a weak reference at another environment. This works well locally when I build with Visual Studio. But when it is been doing with MSBuild at the server, one assembly is not copied to an output directory.

The investigation took me to the GAC where I found this assembly residing. So it looks like MSBuild finds this assembly there and does not copy. But why? The reason is Visual Studio “Copy Local” attribute is not well-synchronized with MSBuild “Private” element.  For example, if you add an assembly from a file path and have not it at GAC. It will set “Copy Local” to true, but there will be no “Private” element at *.csproj. To fix it just toggle twice “Copy Local” attribute or edit *.csproj by hands

This entry was posted in MSBuild, Visual Studio. Bookmark the permalink.

2 Responses to Visual Studio, MSBuild, Copy Local, Private

  1. Craig P says:

    The toggle trick worked as advertised. (VS 2012) Thank you.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s