Search code examples
upgradevisual-studio-2022.net-7.0

Upgrading from .NET 6.0 to .NET 7.0


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


Solution

  • 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