My solution consists of:
Client
- startup project, UI layer. Depends on: App
App
- library, application layer, assembler. Depends on: Lib1
, ...
Lib1
- library, business logic layer. Needs a specific file to work properly: ThirdParty.dll
I've added ThirdParty.dll
to the Lib1
project (Add
> Existing Item...
> Add
) and set Copy to Output Directory
property of dll file to Copy Always
. Now the dll file is copied to the Lib1
output and to the App
output, but not to the Client
output where I need it to be.
What is the right (simple? obvious?) way to copy ThirdParty.dll
to the output of Client
on each solution build?
UPD
ThirdParty.dll
is not a reference. Actually, that's another reference dependence. My question is applied to any file that needs to be in the folder of running application.
Recorded video to be sure I'm doing it right: http://youtu.be/QwS2tOIc5yQ
Add Existing Item as Link:
I had a similar issue in VS2010
and I kinda ended up adding the file as Link
and updating its property to Copy Always
.
In your case, in CLIENT
project, add ThirdParty.dll
as Link
(Add > Existing Item > Add as Link) and set Copy to Output Directory
property of dll file to Copy Always
.
Note: It would copy the folder hierarchy from Project Node.
Just for Reference: I was actually using an open source LibGit2Sharp which required a dll (libGit2.dll) to be available in the output directory. Therefore, in the UI layer, which had added application layer containing LibGit2Sharp.dll
as reference; I had to add libGit2.dll
as a Link
+ Copy Always
. This was recommended solution.
Post Build:
The other option could be to write a post build scripts for CLIENT
To know how the Copy
on MSBuild
works, you could refer to Microsoft.Common.targets
file (should be available @ C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets in your system)
<Target
Name="CopyFilesToOutputDirectory"
DependsOnTargets="
ComputeIntermediateSatelliteAssemblies;
_CopyFilesMarkedCopyLocal;
_CopySourceItemsToOutputDirectory;
_CopyAppConfigFile;
_CopyManifestFiles;
_CheckForCompileOutputs;
_SGenCheckForOutputs">