I have built and deployed a dotnet 6 6.0.300 application under IIS. The application contains this global.json file:
{
"sdk": {
"version": "6.0.300"
}
}
The IIS app pool is configured to use No Managed Code under the .NET CLR version.
There is a previous version of dotnet (3.1.421) installed.
If I run the dotnet --version command I see 3.1.425 and dotnet --info shows:
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.31 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.31 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.31 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
How can I confirm conclusively that the net6 version is being used to run the application?
--versionoutputs the SDK version, not runtime. From the docs:It has nothing to do with runtime selected for your app during runtime.
And you can be completely sure that older major runtime version will never be used because runtime selection does not support rolling backwards to the previous major version (for quite obvious reasons).
From the .NET version selection doc:
The application contains this global.json file
global.jsondetermines SDK used to build the app, but required runtime is determined by the specified target framework (i.e. you can use .NET 7 SDK to build .NET 6 app).But if you want to be really-really sure you can always check the version programmatically: