Resolve platform specific path at install time
authorWoongsuk Cho <ws77.cho@samsung.com>
Wed, 21 Oct 2020 05:12:26 +0000 (14:12 +0900)
committer조웅석/Common Platform Lab(SR)/Principal Engineer/삼성전자 <ws77.cho@samsung.com>
Fri, 18 Dec 2020 00:54:43 +0000 (09:54 +0900)
commitf94a2ac1b626eb05abfda98452b5ea3414420100
treecf8c53db09c32408c1ef71f448ff94f1bebae817
parent1f0d405dcbffdc995d8cf932323a50c5c8a838a6
Resolve platform specific path at install time

If you publish .NET Application without RID designation, it is generated to cross-platform type.
If the .NET application uses a NuGet package that has platform-specific implementations,
all platforms' dependencies are copied to the publish folder along with the app.
(refer to https://docs.microsoft.com/en-us/dotnet/core/deploying)

Libraries and assemblies used for each platform are stored in different locations according to RID and TFM as follows.
(refer to https://natemcmaster.com/blog/2016/05/19/nuget3-rid-graph)

.NET Runtime finds the most suitable paths for its execution environment and uses it by setting APP_PATH and NATIVE_LIBRARY_SEASRCHING_PATH.
These path is set in the coreclr_initializae() function.

Unfortunately, in the case of the candidate process, we cannot specify these kind of paths because a application has not been fixed yet.
So, in the current implementation, all possible combinations of paths are added in priority order.
For this reason, unnecessarily long path settings are being transferred to runtime.

To solve this problem, at the time of installation, I try to change it as if the application was published with the RID setting.
In detail, find the best matched RID and TFM path in the application, and move all contents in them to the "bin" folder.
After then, we can remove runtimes foldr.

The results after resolving are the same as those performed by specifying RID during publish.
NativeLauncher/installer-plugin/delete_unused_library_plugin.cc
NativeLauncher/tool/tac_common.cc
NativeLauncher/util/path_manager.cc