I have .NET6 application and I want to run this application on a specific .NET6 runtime version.
Let's say I have 2 .NET6 runtimes installed on my machine, i.e. 6.0.21 and 6.0.26. I want my .NET6 application to run on 6.0.21 runtime NOT on 6.0.26. It is always taking the latest 6.0.26 runtime only. How do I achieve this ?
I tried below 2 options to achieve this but didn't help,
- By setting
<RuntimeFrameworkVersion>6.0.21</RuntimeFrameworkVersion>in the csproj file - By adding global.json file with below entries
{
"runtime": {
"version": "6.0.21"
}
}
Please note that to identify the runtime used by application, I added below line of code in the application which tells what is the runtime used. Currently it is displaying 6.0.26.
RuntimeInformation.FrameworkDescription
Kindly let me know if there is any other way to achieve this?
Use
.runtimeconfig.json, note that rollForward must be set to DisableUse command line option
--fx-version