Copying a file in .NET Core .csproj file

巧了我就是萌 提交于 2020-01-17 06:35:12

问题


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

回答1:


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).

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

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

</ItemGroup>


来源:https://stackoverflow.com/questions/42750318/copying-a-file-in-net-core-csproj-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!