Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i place native dependencies in a subfolder

When i publish a dotnet core project, it generated a single folder with hundreds of framework and native runtime files in it.

I understand that these files are required to make everything work, but can i move them into a subfolder and still get my app to run?

For example

MYAppFolder\
    MyApp.exe
    MyApp.exe.config
    native\
       hostfxr.dll
       netstandard.dll
       ...

Is there some sort of probing path configuration that can do this?

like image 371
AlgorithmsAreCool Avatar asked Dec 15 '17 21:12

AlgorithmsAreCool


1 Answers

As far as I can see you have a Standalone (SCD) app.

For that type of deployment hostfxr.dll should always exist in the app directory by convention.

As to other deps, you are able to move them to any locations, however you'll need to edit [AppName].deps.json for every build and also specify Additional probing paths. Besides, you are free to remove all the redundant dependencies (from deps.json and the file itself) if you are sure that you don't use them.

Check this demo where I've put all the dependencies of a Standalone app that could be moved to other location to a lib subdirectory.

please, note the following:

  • Additional probing path is set in HelloWorld.runtimeconfig.json but you can also use --additionalprobingpath [path] argument or Environment varibable
  • I've removed relative paths in deps.json file because otherwise I would have put the files to those relative paths sub directories - Additional probing path is considered to be a NuGet package cache thus have a package layout inside.

Also, consider having a Portable (FDD) type. You'll have a much less footprint and more flexibility arranging the files.

like image 95
Ivan Zaruba Avatar answered Oct 07 '22 03:10

Ivan Zaruba