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

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

问题描述

我正在标准 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="....externalsMyLibrariesADll.dll">
  <Link>TidyFolderADll.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="....externalsMyLibrariesADll.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.

推荐答案

考虑将它们添加为嵌入式资源:

Consider adding them as embedded resource:

  <ItemGroup>
    <EmbeddedResource Include="....externalsMyLibrariesADll.dll">
      <Link>TidyFolderADll.dll</Link>
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </EmbeddedResource>
  </ItemGroup>

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

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