Skip to content

Instantly share code, notes, and snippets.

@cchitsiang
Created November 1, 2013 10:38
Show Gist options
  • Save cchitsiang/7263662 to your computer and use it in GitHub Desktop.
Save cchitsiang/7263662 to your computer and use it in GitHub Desktop.
Copying linked content files at each build using MSBuild
<!--http://mattperdeck.com/post/Copying-linked-content-files-at-each-build-using-MSBuild.aspx-->
<Target Name="CopyLinkedContentFiles" BeforeTargets="Build">
<Copy SourceFiles="%(Content.Identity)"
DestinationFiles="%(Content.Link)"
SkipUnchangedFiles='true'
OverwriteReadOnlyFiles='true'
Condition="'%(Content.Link)' != ''" />
</Target>
<!--
This target uses BeforeTargets to ensure it is executed each time a build happens, even when no files in the project need to be built.
The Copy task uses a Condition to filter out all items in the Content item group that do not have a Link meta. This way, the copy is only applied to links. To speed up the process, it sets SkipUnchangedFiles to true, so if a linked file has not been changed, it won't be copied.
-->
<!-- This is linked file -->
<Content Include="..\..\JSNLog\Scripts\jsnlog.js">
<Link>Scripts\jsnlog\jsnlog.js</Link>
</Content>
@antanta
Copy link

antanta commented Sep 27, 2017

Thank you. Only solution so far which worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment