-
Notifications
You must be signed in to change notification settings - Fork 266
Description
NuGet Product(s) Involved
dotnet.exe
The Elevator Pitch
The dotnet CLI would like to compile and distribute itself as a Native AOT application (dotnet/sdk#49667), to take advantage of faster startup times and eliminate unnecessary CoreCLR startup overhead. To do this, we need our partner libraries and tools to be AOT/Trimming compatible. While doing initial testing we found that several libraries that we use report trimming warnings, and we'd like to request that a future version of those libraries be made trim-compatible.
The namespaces that we use that would need to be compatible are:
- NuGet.Client
- NuGet.Common
- NuGet.Configuration
- NuGet.ContentModel
- NuGet.Credentials
- NuGet.DependencyResolver
- NuGet.Frameworks
- NuGet.LibraryModel
- NuGet.Packaging
- NuGet.Packaging.Core
- NuGet.Packaging.Signing
- NuGet.ProjectModel
- NuGet.Protocol
- NuGet.Protocol.Core.Types
- NuGet.Repositories
- NuGet.RuntimeModel
- NuGet.Versioning
I took a look at NuGet.Client myself, and broadly saw three areas of work while investigating the impact of marking libraries "IsAotCompatible=true":
- Assembly loads to get dll version information for NuGet libraries themselves
- Json serialization that is reflection-based instead of source-generated
- A complex version-property setting scheme that uses a delegate for the PackArgs type that I didn't see a good way to work around
In addition, I believe that making these libraries Trimming-compatible would require having a new .NET-specific TFM. While that would make ifdefs, etc more cumbersome, I think it might be a blessing in disguise as that would mean you could potentially limit any breaking API changes to the new TFM only.
There may be more items, however, as I am not fully up to speed on the NuGet codebase.
Additional Context and Details
There are some helpful resources that I found:
- .NET Blog post describing how to make libraries AOT-compatible
- List of trimming incompatibilities
- Native AOT docs root
- My hacked-up fork of NuGet.Client demonstrating some of the changes
To sweeten the pot a bit, we need NuGet libraries to be AOT-able in order to make a fully-native tool that can fill the role of dnx - using NuGet APIs to interact with feeds, manage packages, etc. With this, we can make .NET SDK Tools super easy to use, without dragging in the whole SDK payload.