Given aspnet project with folders:
/
/sql
/WebApp
/Client
/wwwroot
/Views
On project.json I used
\"publishO
Update:
When using VS 2017 >= 15.3 or a .NET CLI version >= 2.0, there is a new feature that automatically adds Link
metadata for a few known item types (including Content
). This can be used like:
<Content Include="..\sql\**" LinkBase="sql" />
Original:
You can use this:
<ItemGroup>
<Content Remove="Client\**" />
<Content Include="..\sql\**" CopyToPublishDirectory="PreserveNewest" Link="sql\%(RecursiveDir)\%(Filename)%(Extension)" />
</ItemGroup>
The content include item's link metadata is a bit of hack to make MSBuild use the item's relative path as target path. This is because items outside of the "project cone" aren't considered in AssignTargetPath
if they have no Link
metadata (source).
Alternative to <Content Remove="..." />
you can also do this to still have the files inside VS:
<Content Update="Client\**" CopyToPublishDirectory="Never" />