Started to get "This project is targeting a version of .NET which is not installed", but it had worked fine before

Rod Falanga 591 Reputation points
2022-02-16T02:04:07.783+00:00

Before VS 2022 came out I started working on a .NET 5 API project using VS 2019. When VS 2022 came out I switched to using VS 2022. All was fine. No problems, I've been able to continue working on the project, adding new code/functionality, saving, etc.

That is until tonight. I noticed that there was an update to VS 2022, so I applied the update with the VS Installer. I am now at version 17.1.0 of VS 2022. I made some changes and was about to commit them, when I got this warning message within VS 2022:

This project is targeting a version of .NET which is not installed.

Then there's an Install link to the right of the warning message.

I'm confused by this warning message. First, I still have VS 2019 installed on this machine and it is up to date as well. (I checked when I brought up the VS Installer.) That means I do have .NET 5 on this machine. Secondly, why didn't VS 2022 complain about this earlier, when I first started modifying the code a couple of months back? I don't understand why it is a problem now, but previously everything was good.

Developer technologies Visual Studio Other
{count} votes

4 answers

Sort by: Most helpful
  1. Aaron Seet 726 Reputation points
    2022-03-02T10:59:10.34+00:00

    Unfortunate "me too" comment. VS complains right after 17.1.0 update. Why would its components listed them uninstalled/unchecked when they're present?

    PS C:\projects\cdk\src> dotnet --info
    .NET SDK (reflecting any global.json):
    Version: 6.0.200
    Commit: 4c30de7899
    OS Name: Windows
    OS Version: 10.0.19043
    OS Platform: Windows
    RID: win10-x64
    Base Path: C:\Program Files\dotnet\sdk\6.0.200\

    Host (useful for support):
    Version: 6.0.2
    Commit: 839cdfb0ec

    .NET SDKs installed:
    2.1.526 [C:\Program Files\dotnet\sdk]
    2.2.207 [C:\Program Files\dotnet\sdk]
    3.1.301 [C:\Program Files\dotnet\sdk]
    3.1.416 [C:\Program Files\dotnet\sdk]
    5.0.303 [C:\Program Files\dotnet\sdk]
    5.0.405 [C:\Program Files\dotnet\sdk]
    6.0.200 [C:\Program Files\dotnet\sdk]

    .NET runtimes installed:
    Microsoft.AspNetCore.All 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
    Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
    Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
    Microsoft.AspNetCore.App 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
    Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
    Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
    Microsoft.AspNetCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
    Microsoft.AspNetCore.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
    Microsoft.AspNetCore.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
    Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
    Microsoft.AspNetCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
    Microsoft.AspNetCore.App 5.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
    Microsoft.AspNetCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
    Microsoft.NETCore.App 2.1.19 [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 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
    Microsoft.NETCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
    Microsoft.NETCore.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
    Microsoft.NETCore.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
    Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
    Microsoft.NETCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
    Microsoft.NETCore.App 5.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
    Microsoft.NETCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
    Microsoft.WindowsDesktop.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
    Microsoft.WindowsDesktop.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
    Microsoft.WindowsDesktop.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
    Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
    Microsoft.WindowsDesktop.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
    Microsoft.WindowsDesktop.App 5.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
    Microsoft.WindowsDesktop.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

    1 person found this answer helpful.
    0 comments No comments

  2. Jerry Lanphear 1 Reputation point
    2022-05-01T19:08:11.957+00:00

    Hi Rod. Nice to interact with you again. I installed VS 2022 for the first time today and experienced the same issue. I did notice however that my Blazor application targeting .NET 5 still compiles and runs in spite of the warning. Quite a feat for something that is not installed.

    One would think that someone would want to get on such an embarrassing error and get it fixed.

    0 comments No comments

  3. Eric Claiborne 1 Reputation point
    2022-05-05T13:11:19.397+00:00

    I have VS2019 & VS2022 both installed. I migrated project to VS2022 about 1 month ago, working fine. Yesterday, I updated VS2022 to 17.1.6 and I suddenly got the same ".NET not installed" message. As @Tianyu Sun-MSFT said to do, I ran the VS installer and sure enough .Net 5.0 and 3.1 Runtimes were NOT checked. I checked them both and the project is now loading without issues. I suppose I could have just clicked the "Install Fix" link, but I don't click on things unless I know what it's doing. Thank you for the fix!

    However, there goes another few hours dealing with another bad VS update (several problems in the past). I am a huge "Microsoft Guy" and glad to see help is being provided to this issue. However, I am also concerned that VS2019 and VS2022 are so unstable these days. I've used VS since the late 90's and it was always the best IDE and very stable. Over the last two years or so, it seems like VS and this Blazor project are the most problems I have ever had with VS. I don't care about "rapid release" of VS versions. I want "reliable release". We are out here trying to build projects that last for years and MS keeps moving the dang ball on us! Get stable so we can work!


  4. Lorin Chamlee 1 Reputation point
    2022-09-22T12:30:41.457+00:00

    Just adding some extra here for anyone finding this is the future; I just ran into this issue recently during the latest VS2022 update...

    The issue for me was the global.json file in the project root folder:

    {  
        "sdk": {  
            "version": "6.0.400",  
            "rollForward": "disable"  
        }  
    }  
    

    The update removed 6.0.400 and installed 6.0.401, so after I changed this in the global.json everything was good.
    You could also experiment with the rollForward feature, but I have not tested that.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.