Handling common JavaScript files in Visual Studio 2010

I know this issue is ancient, but still wanted to put forward my solution because it is a bit simpler than beardtwizzle’s.

You can ensure that Visual Studio copies all linked files to where you placed the link in Visual Studio’s Solution Explorer by adding this at the end of your .csproj file:

  <Target Name="CopyLinkedContentFiles" BeforeTargets="Build">
    <Copy SourceFiles="%(Content.Identity)" 
          DestinationFiles="%(Content.Link)" 
          SkipUnchangedFiles="true" 
          OverwriteReadOnlyFiles="true" 
          Condition="'%(Content.Link)' != ''" />
  </Target>

I’ve described how this works in my blog post at
http://mattperdeck.com/post/Copying-linked-content-files-at-each-build-using-MSBuild.aspx

Leave a Comment