Copy entire directory to output folder maintaining the folder structure?

Try XCOPY instead of COPY; e.g.

XCOPY "$(SolutionDir)Resources\Template\" "$(TargetDir)\Template" /s /i /y

More info on XCOPY here...

http://www.computerhope.com/xcopyhlp.htm


This worked for me. /S is the key which copies everything recursively.

XCOPY "$(SolutionDir)Resources\Template" "$(TargetDir)\Template\" /S

Since I wanted files to be overwritten every time without a prompt, I added a /Y switch as well.

XCOPY "$(SolutionDir)Resources\Template" "$(TargetDir)\Template\" /S /Y

I just added this to my *.csproj file (right click Edit Project File)

<ItemGroup>
    <Content Include="MYCUSTOMFOLDER\**">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
</ItemGroup>

I think for this the directory needs to be on same hierarchy level as *.csproj file or bellow that.