作为链接添加到项目文件夹中,以始终复制到输出的根目录 [英] Add as link to within a project folder to copy always to root of output

查看:130
本文介绍了作为链接添加到项目文件夹中,以始终复制到输出的根目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与标准c#项目中的非托管.dll进行互操作.我不能将这些.dll添加为简单引用,而必须使用P/Invoke来实际使用它们.它们不包含清单,因此做任何聪明的反射工作来动态地加载它们(从而解决了将它们作为显式的独立文件包含在内的问题)完全是不可能的.

I'm doing some interop with unmanaged .dlls in a standard c# project. I cannot add these .dlls as simple references and have to use P/Invoke to actually use them. They don't include manifests so doing any clever reflection stuff to load these dynamically (And thus solve the problem of including them as explicit, separate files) is simply out of the question.

我与安装程序版本无关,我可以告诉WiX(或我选择的任何安装程序平台)将哪些文件确切放置在目标系统上.

I am not concerned with installer releases, I can tell WiX(Or whatever installer platform I choose) what files to exactly put where on a target system.

问题在于调试输出,我需要这些.DLL与我自己项目的可执行文件并排,但我不希望它们使我的实际托管代码混乱.

The problem is in terms of debugging output, I need these .DLLs side-by-side with my own project's executable, but I don't want them cluttering up my actual managed code.

所以我的情况是这样;

So my situation is this;

  • 我将几个.dll作为链接添加到项目的文件夹中.
  • 我尝试更改.csproj以便在调试输出的根目录下输出链接的文件.

它看起来像这样:

<None Include="..\..\externals\MyLibraries\ADll.dll">
  <Link>TidyFolder\ADll.dll</Link>
  <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>

现在,通常您可以将<Link>标记更改为要输出的位置,但是要这样做:

Now, normally you'd change the <Link> tag to where you want the output to go, but doing this:

<None Include="..\..\externals\MyLibraries\ADll.dll">
  <Link>ADll.dll</Link>
  <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>

更改链接的.dll所在项目浏览器中的文件夹;它确实可以正确输出,但是杂乱无章是不可取的,也是我首先要将它们放入文件夹的原因.

Changes the folder the linked .dlls are residing in within my project explorer; it does output correctly, but the clutter is undesirable and the reason why I wanted to throw them into a folder in the first place.

TL; DR:如何同时控制链接项目在项目中可见的位置以及调试时其输出位置.

TL;DR: How can you simultaneously control where a linked item is visible within a project, as well as its output location on debug.

推荐答案

为什么不将它们添加为嵌入式资源:

Why not adding them as embedded resource:

  <ItemGroup>
    <EmbeddedResource Include="..\..\externals\MyLibraries\ADll.dll">
      <Link>TidyFolder\ADll.dll</Link>
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </EmbeddedResource>
  </ItemGroup>

这篇关于作为链接添加到项目文件夹中,以始终复制到输出的根目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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