Description
Background
Our scenario is we have multiple teams working independently on apps/components that need to ship together in a single package. To save space in that package, we are going to AOT compile all of these apps/components together (as opposed to AOT compiling them individually). The goal is to fold together similar code and de-duplicate .NET runtime and .NET libraries which are heavily overlapping between these components.
However, the components may take the same nuget dependencies at different versions. In order to AOT compile them together we must choose one of the nuget dependencies for the AOT compilation but if the API contract across nuget versions is not stable, this doesn't work.
For nuget packages we own I have figured out a trick that I can encode the version number of the nuget package into the AssemblyName of the dlls, which helps partition these assemblies in the AOT compilation because they are now distinct from the perspective of ILC.
Feature Proposal
The request is to support loading conflicting assembly references in "islands" for AOT compilation. In terms of .NET APIs this is similar to AssemblyLoadContext where I want to isolate assembly loads within a single runtime, but in AOT compilation I don't have any way to influence how the assemblies are loaded into ILC.
From an authoring perspective this might look an attribute on the Reference tag, similar to "Aliases".
<Reference Include="NugetPackage.1.1.0\Library.dll" AssemblyLoadContext="Island1" />
<Reference Include="NugetPackage.1.2.0\Library.dll" AssemblyLoadContext="Island2" />
Alternatives considered
The extern alias
is similar to what we want here, but I don't have any influence over the consuming assemblies as the conflicting dependencies may be via transitive nuget references and not in assemblies I have control over.
I also have thought about doing ildasm
, replacing assembly references with versioned assembly names , and then putting it back together with ilasm
. I haven't tried this, but if folks this might be viable I can pursue it.
I'm open to other suggestions for how to accomplish this goal!