Upgrading from .NET 6.0 to .NET 7.0
Asked Answered
F

2

6

For a current visual studio 2022 solution I am trying to change the target framework from .NET 6.0 to .NET 7.0. I have downloaded the sdk for this and if I go to create a new solution, .NET 7.0 is now an option for the targeted framework. However, for a current solution, the highest I can still go is .NET 6.0

enter image description here

I've been trying to look online, and changed it visual studio to preview mode but that didn't change anything, what do I need to do in order for .NET 7.0 to be an option here? If I just try change the .csproj file I get the error "The current .NET SDK does not support targeting .NET 7.0. Either target .NET6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0". What am I missing here?

Edit:

I have noticed as well that even if I create a new project within the existing solution,.NET 7.0 is an option for the targeted framework, it's just not an option for the existing ones for some reason

Flocculate answered 13/3, 2023 at 9:16 Comment(1)
This is a very useful and relevant piece of documentation: learn.microsoft.com/en-us/aspnet/core/migration/60-70 Even if not using ASP.NET Core, read it. Do not miss the link to the list of breaking changes at the end.Finnie
F
5

Figured out what was going on. There is a global.json file which I didn't realise was there. It was set up like so:

{
  "sdk": {
    "version": "6.0.100",
    "rollForward": "latestMinor"
  }
}

I just needed to change it to:

{
  "sdk": {
    "version": "7.0.100",
    "rollForward": "latestMinor"
  }
}

Doing this solved my problem and I was then able to select .NET 7.0 as the targeted framework

Flocculate answered 13/3, 2023 at 10:22 Comment(0)
B
1

In my case i had to update the .csproj file

 <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

I had to change TargetFramework from net6.0 to net7.0

Brannon answered 14/10, 2023 at 17:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.