Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find & set .Net6 as Target Framework with VisualStudio2022 #8493

Closed
lingxiao-microsoft opened this issue May 26, 2023 · 9 comments
Closed
Labels
area-setup Issues related to installing .NET Core needs-more-info Not enough information has been provided. Please share more detail as requested.

Comments

@lingxiao-microsoft
Copy link

lingxiao-microsoft commented May 26, 2023

Hello Team,

I'm trying to setup the workspace for .Net6 development environment.

I've installed the VS2022 with newest release (also tested with older version like 17.5.4) and specifically installed the .Net6 SDK. See below results from cmd & folder

image
image

Then I used the VS2022 to create a completely new project with ConsoleApp type.

During the creation steps, I was able to see the .Net6 option and select it

image

But after the project is created and try to build the solution, it gave me below errors.

image

And from the solution properties, I was not able to see the .Net6 sdk from the dropdown list

image

I've downloaded the .Net6 SDK from here for x64. (Also tried with x86 and did not work as well)

Please kindly let us know how could we resolve the issue as it is blocking us, would really appreciate it!

Thanks again!

@steveharter steveharter added the area-setup Issues related to installing .NET Core label May 26, 2023
@steveharter
Copy link
Member

Is there a global.json file in the directory of your project or any parent directory? That overrides the SDK lookup.

@steveharter steveharter added the needs-more-info Not enough information has been provided. Please share more detail as requested. label May 26, 2023
@lingxiao-microsoft
Copy link
Author

hi @steveharter , there is no global.json.

@lingxiao-microsoft
Copy link
Author

lingxiao-microsoft commented May 26, 2023

However, I previously was using VS2019, I did not uninstall VS2019 before I install the VS2022. This is due to I still need some dev work using VS2019. But again, there should not be a global.json file.

@mairaw
Copy link
Contributor

mairaw commented May 26, 2023

What does your csproj look like?
It's interesting that the dropdown is only showing .NET Framework versions. I see this on VS for a console project
image

You should be able to run VS versions side-by-side, so having VS 2019 and VS 2022 shouldn't be a problem.

Can you also check what where.exe dotnet returns?

@lingxiao-microsoft
Copy link
Author

Hi @mairaw , it's a vanilla console app project.

Below is the csproj file

image

And this is the result from the cmd you mentioned

image

@lingxiao-microsoft
Copy link
Author

The second file location is where I've currently installed my .Net6 SDK.

The 1st one is a previous login to Windows which is no longer in used. currently I'm using lingxiaoli.REDMOND

@mairaw
Copy link
Contributor

mairaw commented May 26, 2023

I'd try to change the path so the second entry comes first or simply remove the first entry from the PATH. This might be messing VS.

Some instructions on how to do that can be found at #5962 (comment)

@lingxiao-microsoft
Copy link
Author

lingxiao-microsoft commented May 26, 2023

Hi @mairaw , it looks like when building the solution, it is still trying to look for the SDK under this path.

C:\Program Files\dotnet\sdk\Microsoft.NET.Sdk.Worker\Sdk

However, from my dotnet folder, the layout should look like below format

C:\Program Files\dotnet\sdk\<dotnet-version>\Microsoft.NET.Sdk.Worker\Sdk

Do you know how to fix the issue?

@lingxiao-microsoft
Copy link
Author

I've uninstalled all SDKs, runtime related to .Net6 and reinstalled VS22 completely. The issue seems resolved for me now, thank you for help on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-setup Issues related to installing .NET Core needs-more-info Not enough information has been provided. Please share more detail as requested.
Projects
None yet
Development

No branches or pull requests

3 participants