问题
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