Question:
Can't build and run console application solutions in Visual Studio 2022?

Problem:

I'm using Visual Studio 2022 and .NET 6.0. When I create a console app, in my solution explorer, I only get an icon for a solution. But there are no project and class items, no properties and references.



I made many console applications some years ago, but I think it was an older version of .NET, but I am not sure. The structure then was like this:


enter image description here


Another problem is that I can't build and execute the console app, with or without debugging. Options are locked.

enter image description here


I recently made a few MAUI and Blazor apps for learning and practicing and I didn't have any problems with these types of apps.


This is the output of dotnet --info:


Solution:

After >a lot of back and forth, the problem was that

  1. Your dotnet CLI install was the x86 version, and

  2. The x86 version of the CLI had no SDKs installed.

This was also evident by running where dotnet in CMD. In my case, where I'm using the x64 version, "C:\Program Files\dotnet" comes before "C:\Program Files (x86)\dotnet". You had it backwards, even though your OS is x64. My guess is that your dotnet install is really old and that's what it was way back in the day.


There's two ways to fix this:

  1. Install the .NET SDK for x86, and keep using x86.

  2. (which we ended up doing) Changing the CLI to be x64. This was done by changing the system-level PATH variable to have "Program Files" above "Program Files (x86)", as suggested >in this page.


Suggested blogs:

>Set up Node.js & connect to a MongoDB Database Using Node.js

>Setting up a Cloud Composer environment: Step-by-step guide

>What is microservice architecture, and why is it better than monolithic architecture?

>What is pipe in Angular?

>What makes Python 'flow' with HTML nicely as compared to PHP?

>What to do when MQTT terminates an infinite loop while subscribing to a topic in Python?

>Creating custom required rule - Laravel validation

>How to configure transfers for different accounts in stripe with laravel?

>Laravel Query Solved: Laravel withOnly not restricting the query


Ritu Singh

Ritu Singh

Submit
0 Answers