如何将必需文件包含到独立客户机项目的输出中? [英] How to include neccessary files to the output of independent client project?

查看:134
本文介绍了如何将必需文件包含到独立客户机项目的输出中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的解决方案包括:

客户端 - 启动项目,UI层。取决于:应用程序

Client - startup project, UI layer. Depends on: App

应用程序 - 库,应用程序层,汇编器。取决于: Lib1 ,...

App - library, application layer, assembler. Depends on: Lib1, ...

Lib1 - 图书馆,业务逻辑层。需要一个特定的文件才能正常工作: ThirdParty.dll

Lib1 - library, business logic layer. Needs a specific file to work properly: ThirdParty.dll

我添加了 ThirdParty .dll Lib1 项目(添加> 现有项目... > 添加)并将复制到dll文件的输出目录属性复制始终。现在,dll文件被复制到 Lib1 输出和 App 输出,而不是客户端输出,我需要它。

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.

什么是正确的(简单明了?)复制方式 ThirdParty.dll 到每个解决方案构建的客户端的输出

What is the right (simple? obvious?) way to copy ThirdParty.dll to the output of Client on each solution build?

UPD
ThirdParty.dll 不是引用。其实这是另一个参考依赖。我的问题适用于需要在正在运行的应用程序的文件夹中的任何文件。

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.

录制的视频确保我正确地做到: http://youtu.be/QwS2tOIc5yQ

Recorded video to be sure I'm doing it right: http://youtu.be/QwS2tOIc5yQ

推荐答案

将现有项目添加为链接

我在 VS2010中有类似的问题而且我最终将文件添加为 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.

在您的情况下,在 CLIENT 项目中,添加 ThirdParty.dll as 链接(添加>现有项目>添加为链接)并设置复制到输出目录属性dll文件到复制始终
注意:它将从Project Node复制文件夹层次结构。

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.

仅供参考:实际上正在使用一个开源的 LibGit2Sharp ,这需要一个dll(libGit2.dll)才能在输出目录中使用。因此,在添加包含 LibGit2Sharp.dll 的应用程序层的UI层作为参考;我必须添加 libGit2.dll 作为链接 + 复制始终。这是推荐的解决方案。

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.

帖子构建:

另一个选项可能是为客户端编写脚本编写脚本

要知道复制 MSBuild 的工作,你可以参考 Microsoft.Common.targets 文件(应该可用@ C :\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets在您的系统中)

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">

这篇关于如何将必需文件包含到独立客户机项目的输出中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆