'Is there a way to detect the current SDK being used in a .targets MSBuild file?

In .NET, you can specify which .NET project SDK you would like to use by specifying the Sdk attribute on the top-level Project element:

<Project Sdk="Microsoft.NET.Web.Sdk">

I am writing a NuGet package and attempting to find an MSBuild property or item that saves off which SDK is being used. I am not having any luck in the official documentation nor when examining a build in the MSBuild Structured Log Viewer in finding one.

Is there an idiomatic way to identify which Sdk has been selected for a project in an MSBuild .targets file?

I would have expected a property like

$(MSBuildProjectSdkName) // "Microsoft.NET.Web.Sdk"


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source