Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include neccessary files to the output of independent client project?

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

like image 857
astef Avatar asked May 28 '13 11:05

astef


People also ask

How do I add a file to Visual Studio project?

You can add existing files to your project by right-clicking on the Project node and selecting Add > Add Files.... Alternatively, to add an entire folder, select Add > Add Existing Folder.... The file browser is shown. It lets you search your system for the required item to add.

How do I add a solution to an existing project?

Add files to a solution To add an item to a solution, on the context (right-click) menu of the solution node in Solution Explorer, select Add > New Item, or Add > Existing Item. A solution file is a structure for organizing projects in Visual Studio.

How do I add an existing folder to Visual Studio?

Adding FilesRight click the project or contained folder and choose Add | Existing Item... . Use Show All Files . Click on files or folders you would like to add to the project and choose Include In Project . Drag and drop files and folders from Windows Explorer.

How do I add an existing project to a solution in Visual Studio?

To add an existing project to a solutionIn Solution Explorer, select the solution. On the File menu, point to Add, and click Existing Project. In the Add Existing Project dialog box, locate the project you want to add, select the project file, and then click Open. The project is added to the selected solution.


1 Answers

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">
like image 176
jacob aloysious Avatar answered Sep 24 '22 00:09

jacob aloysious