0

I'm developing an ASP.NET Core 1.0 application which I deploy to a Linux machine using Docker.

In my CI pipeline I'm publishing the project using dnu publish, then I build the docker image with docker build.

I have a static binary file that I need to use in my docker image. (It's a hotfix which I need to copy into the coreclr runtime directory.) I want to be able to access that file with a command from my Dockerfile.

What is the idiomatic, reliable way to make that file get copied into the output directory when I'm doing dnu publish? What I'm currently doing - because I couldn't find a better solution - is adding it to wwwroot, so it gets copied into wwwroot in the output folder.
However, I don't want that file to be publicly accessible, it would be much better to make it end up in approot.

The approaches I found on SO and tried, but are not working:

  • Including the file in the project.json as "contentFiles": [ "mylib.so" ]. If I do this, I get the following error during the dnx build:
    Error: The process cannot access the file 'C:\myapp\src\myapp.web\mylib.so' because it is being used by another process.
  • I tried to experiment with creating a custom postBuild script (found the suggestion here: New .NET "project.json" project, copying pre-built native .dlls to the output directory), but I can't figure out where to copy the file, since I have different CI pipelines publishing the same project using different publish output directories, so I cannot hardcode the directory path into my project.json.
    Or is there a way to copy it into the build directory, which will be picked up by dnu publish regardless of the output directory of publish?
Community
  • 1
  • 1
Mark Vincze
  • 7,737
  • 8
  • 42
  • 81
  • 1
    You could write an middleware to check and block access to a certain folder, i.e /bin (wwwroot/bin) or set `OnPrepareResponse` on `StaticFileOptions` (see http://stackoverflow.com/a/34669398/455493 for an example) – Tseng Feb 22 '16 at 11:04
  • Good idea, thanks! It feels a bit hacky though, but I'll definitely try if I can't find a proper solution outputting the files in `approot`. – Mark Vincze Feb 22 '16 at 12:39

0 Answers0