Share via

Why I could not build this "https://developer.microsoft.com/en-us/graph/quick-start" using VS 2022

Phong Nguyen 0 Reputation points
2023-06-21T17:40:15.13+00:00

When play with this Microsoft Graph quick start project, I open it in my MS 2022, rebuild the solution, but get this error :"Error NETSDK1045 The current .NET SDK does not support targeting .NET 7.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0. GraphTutorial C:\Program Files\dotnet\sdk\6.0.313\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets". BUT But I build it in my cmd window, it works OK?

I download .Net 7.0.304 and see it in my C:\Program Files\dotnet\sdk\ and also see this sample using .Net 7 (in the Readme).

Community Center | Not monitored
0 comments No comments

1 answer

Sort by: Most helpful
  1. Anna Xiu-MSFT 31,196 Reputation points Microsoft External Staff
    2023-06-22T03:40:13.7966667+00:00

    Hi @Phong Nguyen

    Welcome to Microsoft Q&A! 

    Please have a try with the following workarounds:

    1. Update your VS2022 to the latest version with Visual Studio Installer.
    2. Change the target framework to .NET 7.0 and rebuild your project:
    • Right click on project > Properties > Application > General > Target framework > switch to NET 7.0.
    • Open your project file and check the target framework:
    <TargetFramework>net7.0</TargetFramework>
    

    If the .NET 7.0 is not appeared in Target framework, please close all running VS instances and go to Visual Studio installer > Modify > Individual components > ensure that .NET 7.0 Runtime is checked. 

    1. Check the installed versions of .NET (open a Developer Command Prompt for VS 2022 and run this command):

    dotnet --list-sdks

    You can refer to: NETSDK1045: The current .NET SDK does not support 'newer version' as a target.

    Sincerely,

    Anna


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

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