I have a PackageReference based .NETStandard 2.0 package which includes several content files using the following in the source project:
<ItemGroup>
<Content Include="..\Common\**" PackagePath="contentFiles\any\any\;content" CopyToOutputDirectory="Always" PackageCopyToOutput="true"/>
</ItemGroup>
Common includes several files and subfolders like so:
Common
| file.txt
| Folder\
| file2.txt
| file3.txt
| Folder2\
| file4.txt
| file5.txt
These files show up in the solution explorer and the build output for my consuming project in the same layout as they were within Common. I would like to reorganize files in some of the subfolders in the build output of my consuming project. The resulting structure should be something like follows:
...\netstandard2.0
| file.txt
| Package\
| Folder\
| file2.txt
| file3.txt
| Folder2\
| file4.txt
| file5.txt
I've tried to achieve this using a Copy Task. Something like:
<Target Name="CreateFolder" AfterTargets="AfterBuild">
<Copy SourceFiles="$(OutDir)Folder;$(OutDir)Folder2" DestinationFolder="$(OutDir)Package"/>
</Target>
I've discovered that Copy doesn't actually support specifying the source files from the build directory like this. All other answers on the topic that I've read accomplish Copy with Items declared within an ItemGroup with an Include attribute something like as follows:
<ItemGroup>
<FilesToCopy Include="..\Folder\**;..\Folder2\**"/>
</ItemGroup>
<Target Name="CreateFolder" AfterTargets="AfterBuild">
<Copy SourceFiles="@(FilesToCopy)" DestinationFolder="$(OutDir)Package"/>
</Target>
The issue with this approach is that I can't figure out how to get Include to work with content files from a package as they are not in that physical location in the project.
Documentation for contentfiles is quite sparse and a lot of what I've read is not for PackageReference style projects. Is there an alternative way to accomplish what I want?