Visual Studio:将文件与其包一起复制到输出中 [英] Visual Studio: Copy files into output with their package

查看:43
本文介绍了Visual Studio:将文件与其包一起复制到输出中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为A"的项目项目,它包含一些文件(如 dll 或其他).

I have a project called "A" project, and it contain some files (like dll or others).

在我的主要项目中,我使用了项目参考";引用此项目,并在 A 的 .csproj 中添加一些上下文,如下所示:

In my main project, I used "Project Reference" to reference this project, and add some context into the .csproj of A as follow:

<ItemGroup>
    <ContentWithTargetPath Include="files\MyDll.dll">
        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        <TargetPath>MyDll.dll</TargetPath>
    </ContentWithTargetPath>
</ItemGroup>

看起来不错,文件总是复制到我的主项目的输出文件夹中.

It's looked fine and the files were always copied to the output folder of my main project.

但是在我使 A 项目成为 Nuget 包并且我的主项目使用包参考"之后引用它,A 项目中的文件在我的主项目的输出文件夹中消失了.

But after I make A project become a Nuget package and my main project use "Package Reference" to reference it, the files in A project are gone in output folder of my main project.

有什么办法可以解决吗?

Does have any way to deal with it?

谢谢!

推荐答案

相反,你应该使用:

<PackageCopyToOutput>true</PackageCopyToOutput>

检查 这个问题.

更新

改用这个:

<Content Include="files\MyDll.dll" Pack="true" PackagePath="contentFiles\any\any\MyDll.dll;content\MyDll.dll">
          <PackageCopyToOutput>true</PackageCopyToOutput>
</Content >

这篇关于Visual Studio:将文件与其包一起复制到输出中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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