在.NET Core .csproj文件中复制文件 [英] Copying a file in .NET Core .csproj file

查看:443
本文介绍了在.NET Core .csproj文件中复制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac OS X的.NET Core中创建了一个新的.NET类库项目。在项目构建过程中,我想将文件复制到调试目录中。如何将其添加到 .csproj 文件?

I created a new .NET Class Library project in .NET Core on Mac OS X. During the project build, I'd like to copy a file into the debug directory. How do I add this to the .csproj file?

.NET Command Line Tools (1.0.1)

Product Information:
Version:            1.0.1
Commit SHA-1 hash:  005db40cd1

Runtime Environment:
OS Name:     Mac OS X
OS Version:  10.12
OS Platform: Darwin
RID:         osx.10.12-x64
Base Path:   /usr/local/share/dotnet/sdk/1.0.1


推荐答案

.csproj 文件再次使用MSBuild,这可以通过MSBuild项目完成。您需要为相应的项目添加 CopyToOutputDirectory 属性,并指定复制时间(始终,PreserveNewest,从不)。

As with back to .csproj file the MSBuild is used again, this is can be done by MSBuild items. What you need is to add CopyToOutputDirectory attribute to the corresponding item and specify when to copy (Always, PreserveNewest, Never).

.csproj文件中的部分示例(来自此处):

Example of the section in .csproj file (from here):

<ItemGroup>
    <None Include="notes.txt" CopyToOutputDirectory="Always" />
    <!-- CopyToOutputDirectory = { Always, PreserveNewest, Never } -->

</ItemGroup>

这篇关于在.NET Core .csproj文件中复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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