Skip to content

Add a way to list native assets that a project will load from the app directory (list them in deps.json) #11373

Open

Description

Image for: Description

In dotnet/runtime we're currently enabling a feature for applications to carry their own copy of ICU for globalization purposes instead of using system-wide installed ICU.

In order to make this feature work, we're using NativeLibrary.TryLoad API which uses some probing using NATIVE_DLL_SEARCH_DIRECTORIES property passed by the host to the runtime. However, this property is populated based of the deps.json file, so if we don't have any native assets coming from NuGet packages or we want to use a different folder for our custom built native assets, we wont be able to load from there as NATIVE_DLL_SEARCH_DIRECTORIES will not include this directory. This is of course blocking for framework dependent apps as for self contained apps NATIVE_DLL_SEARCH_DIRECTORIES includes the app directory always.

Currently the only way to have native assets included in deps.json file is via NuGet resolved assets, however, I did manage to do this by adding:

  <ItemGroup>
    <IcuAssemblies Include="icu\*.so*" />
    <RuntimeTargetsCopyLocalItems Include="@(IcuAssemblies)" AssetType="native" CopyLocal="true" DestinationSubDirectory="runtimes/linux-x64/native/" DestinationSubPath="%(FileName)%(Extension)" RuntimeIdentifier="linux-x64" NuGetPackageId="System.Private.Runtime.UnicodeData" />
  </ItemGroup>

This requires me to specify a NuGetPackageId and it has to be an actual package that the app references, so if I have a project that doesn't reference any NuGet packages, then I won't be able to do this.

Open questions

Image for: Open questions

Should assets specify a RID or should the SDK assume it, based on the publish/build rid?
How should they be listed in the deps.json file? Under the built app library section? Under a new loose native assets section?
We need to make sure this works end-to-end on publish, packaging and as transitive dependencies as what if I have a reference to an app that depends on this loose native assets?

Notes

Image for: Notes

This will be a very important feature for ICU story since we're now providing a default behavior to use ICU on Windows and many customers will want to use the same version or a custom version with custom locales in their app across different OSs.

cc: @dsplaisted @ericstj @jkotas @tarekgh @eerhardt @jeffschwMSFT

Metadata

Image for: Metadata

Metadata

Image for: Metadata

Assignees

No one assigned

    Labels

    Feature Requestnative-assetsIssues related to how the SDK should deal with Native assets

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Image for: Issue actions