SdkResolver.Register(SdkResolver) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Registers an SdkResolver to be consulted during SDK resolution by a host that runs the MSBuild engine in-process (for example the .NET SDK CLI), without MSBuild discovering and loading it from disk by reflection.
public:
static void Register(Microsoft::Build::Framework::SdkResolver ^ resolver);
public static void Register(Microsoft.Build.Framework.SdkResolver resolver);
static member Register : Microsoft.Build.Framework.SdkResolver -> unit
Public Shared Sub Register (resolver As SdkResolver)
Parameters
- resolver
- SdkResolver
The resolver instance to register.
Exceptions
resolver is null.
Remarks
This is the supported way to provide SDK resolvers in a trimmed or Native AOT host, where the on-disk SdkResolvers probing and reflection-based loading used for plugin resolvers are unavailable. The registered resolver is consulted on the same reflection-free code path as MSBuild's built-in resolver, so it never triggers the dynamic-loading failure (MSB4282).
The registered resolver participates in resolution in Priority order alongside MSBuild's built-in resolver, with no assembly loading or reflection. It is consulted for every SDK reference in the process.
Intended to be called once per resolver during host initialization, before the first project is evaluated. The set of registered resolvers is captured the first time an SDK is resolved in the process; registrations performed after that point are not guaranteed to take effect.
This method is thread-safe. Registering the same instance more than once has no additional effect.