Skip to content

Instantly share code, notes, and snippets.

@wallymathieu
Last active March 5, 2021 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wallymathieu/80fa79d0f5e7b5107cbc7e025df2eeaf to your computer and use it in GitHub Desktop.
Save wallymathieu/80fa79d0f5e7b5107cbc7e025df2eeaf to your computer and use it in GitHub Desktop.
Recursive include of c# files in a project
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\SomeOtherProject\SomeFolder\*.cs">
<Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
</Compile>
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<!-- ...
based on https://stackoverflow.com/questions/7643615/how-can-i-get-msbuild-to-copy-all-files-marked-as-content-to-a-folder-preservin
-->
<WWWRoot>$(ProjectDir)wwwroot</WWWRoot>
</PropertyGroup>
<ItemGroup>
<!-- Specify a file collection WWWRootFiles: -->
<WWWRootFiles Include="..\wwwroot\**\*.*"></WWWRootFiles>
</ItemGroup>
<Target Name="CopyContentFiles" AfterTargets="Build">
<!-- Copy files into the relative folder: -->
<Copy SourceFiles="@(WWWRootFiles)"
DestinationFiles="@(WWWRootFiles->'$(WWWRoot)\%(RelativeDir)\%(Filename)%(Extension)')" />
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment