With the new .csproj
format (as well as the old), it is possible to add files as linked outside of the project folder:
I got this working for me (linking all svg-files in an external dir to a solution-subfolder) with a hint from this site. Only the %(Parent.Filename)
didn't work for me (got a CS1508), so I replaced with %(Filename)%(Extension)
.
<ItemGroup>
<Parent Include="C:\Path\To\My\SVG\Dir\*.svg" />
<EmbeddedResource Include="@(Parent)">
<Link>Resources\%(Filename)%(Extension)</Link>
</EmbeddedResource>
</ItemGroup>
While this was previously possible using the %(RecursiveDir)
metadata when using glob expansion ( Link="Resources\%(RecursiveDir)%(Filename)%(Extension)"
), the 2.0.0 version of the .NET Core SDK allows the use of a new LinkBase
metadata:
<EmbeddedResource Include="..\..\..\Demo\**\*.cs" LinkBase="Resources" />
Note that you need to install the 2.0.0 in addition to the recently released VS 2017 15.3 (and ensure no global.json
selects a lower version).
It was introduced with this pull request which is probably the best documentation at the moment.