Paket referencing GitHub files

Paket is a dependency manager for .NET projects, besides referencing NuGet packages, one can reference as well any file from GitHub. Any file from GitHub just by adding single line to paket.dependencies files. Such files would however be added as links to the solution and if they should be picked up by IIS or other web server they need to be copied to it’s location in the solution. Here is how to make sure the files will be copied to their location.

Referencing a file from Github

Adding a reference to file on github, is just a matter of editing paket.dependency file.

github hoonzis/KoExtensions src/KoExtensions.js

Then in the paket references of the project that should reference the file, one has to specify to which folder in the solution this file should be moved.

File:KoExtensions.js scripts

Running paket update will update the project file and add the mentioned file as linked reference:

<Content Include="..\paket-files\hoonzis\KoExtensions\src\KoExtensions.js">

Task to hard copy files

The problem is that if this is simple Content file just as JS file or CSS it won’t be picked up by IIS or other hosting web server, because the web server would just read the folder structure, but the file is not there. The solution is proposed over here

Adding the following build target will copy the linked files to the location where there are linked to.

<Target Name="CopyLinkedContentFiles" BeforeTargets="Build">
 <Copy SourceFiles="%(Content.Identity)"
       Condition="'%(Content.Link)' != ''" />
Written on October 21, 2015