As part of my solution build, I want to copy all "Content" files (asp?x etc) to another folder. Since these are so clearly tagged in the project, I thought there must be an easy way to copy these instead of writing my own post-build step with xcopy. Unfortunately I haven't been able to figure this out - this msbuild thing is incompatible with my brain. I just want a step like but can't figure out the syntax to use.
Bat file syntax suggestions would not be an answer to this question - only pure msbuild solutions apply
Thanks, Per
You can easily do this by the following:
<PropertyGroup>
<DestFolder>..\Copy\</DestFolder>
</PropertyGroup>
<Target Name="CopyContentFiles">
<Copy SourceFiles="@(Content)"
DestinationFiles="@(Content->'$(DestFolder)%(RelativeDir)%(Filename)%(Extension)')"/>
</Target>
If you want to execute this as a post-build steps then you can just add AfterTargets="Build" for example:
<PropertyGroup>
<DestFolder>..\Copy\</DestFolder>
</PropertyGroup>
<Target Name="CopyContentFiles" AfterTargets="Build">
<Copy SourceFiles="@(Content)"
DestinationFiles="@(Content->'$(DestFolder)%(RelativeDir)%(Filename)%(Extension)')"/>
</Target>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With