2

I have these .NET core version SDK installed inside my windows server: -

C:\WINDOWS\system32>dotnet --version
7.0.102

C:\WINDOWS\system32>dotnet --list-sdks
1.0.0-preview2-1-003177 [C:\Program Files\dotnet\sdk]
3.1.426 [C:\Program Files\dotnet\sdk]
6.0.310 [C:\Program Files\dotnet\sdk]
7.0.102 [C:\Program Files\dotnet\sdk]

C:\WINDOWS\system32>dotnet --list-runtimes
Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

but when I created a new ASP.NET Core MVC web application >> and i set the .NET version to 6.0 i got this target framework inside the csproj file:-

<PropertyGroup><TargetFramework>net6.0</TargetFramework></PropertyGroup>

and when I set the .NET version to 7.0 I got this target framework: -

<PropertyGroup><TargetFramework>net7.0</TargetFramework></PropertyGroup>

so my the target framwork is not getting the latest version for the .NET 6.0 which is 6.0.310 and same applies to .NET core 7.0 which is 7.0.102 ??

Thanks

1 Answer 1

2

There is no .net7.0.2 target framework moniker (TFM).

By default

  • when using SDK the latest version is used:

    The .NET CLI must choose an SDK version for every dotnet command. It uses the latest SDK installed on the machine by default, even if:

    • The project targets an earlier version of the .NET runtime.
    • The latest version of the .NET SDK is a preview version.

    This can be affected with global.json file

  • when running framework-depending app it will roll forward to closest patch version:

    The host chooses the latest patch version installed on the machine. For example, if you specified net5.0 in your project file, and 5.0.2 is the latest .NET runtime installed, the 5.0.2 runtime is used.

2
  • thanks for the very usful reply.. so i only need to update the csproj file incase i change the whole .net version let say from 6.0 to 7.0 or from 6.0 to 8.0 ? am i correct? Commented Apr 14, 2023 at 11:00
  • 1
    @microsoftdeveloperdesigner was glad to help! If answer works for you - do not forget to upvote it and mark it as accepted one (checkbox to the left). ". so i only need to update the csproj file" - it depends on your goals, but "by default" - yes, install the SDK and runtime and update the .csproj file.
    – Guru Stron
    Commented Apr 14, 2023 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.