Search code examples
c#visual-studioconsole-application

Visual Studio C# console app doesn't let me specify configuration (also all options are empty)


I haven't opened a Console Application in a hot minute but now I need it to run some benchmarks / complete an intake assignment. This is embarrassing, but I can't even get it set up right, and it's not like I'm a newbie.

sexy image

I'm not doing anything special, it's just empty. Properties of the Solution are also completely empty, so that doesn't help much either.

props

Interestingly enough it didn't even include all language features, e.g. var span = "My String".AsSpan(); doesn't work.

Lastly I have .NET desktop development installed with .NET 7 included. Really confused as to what's wrong.

Steps to recreate:

  1. Launch VS 2022 (17.7.5)
  2. Create a new project
  3. Console App C#
  4. Next
  5. Create

Solution

  • I'm glad you were able to resolve the issue by reinstalling Visual Studio. This really shows that you are extremely lucky. Because usually reinstalling may not solve this issue.

    The reason for saying this is because this issue is usually caused by a problem with the dotnet environment variables. To prove what I'm saying, I need to reproduce your problem first, like this:

    enter image description here

    Then the correct solution to this issue is:

    You can modify the environment variables and find the path "This PC -> Right click 'Properties' -> Advanced system settings -> Environment Variables –> System variables –> double click path"-> Delete "C:\Program Files (x86) \dotnet" and make sure there is "C:\Program Files\dotnet".

    enter image description here

    enter image description here

    enter image description here

    enter image description here

    Of course, it may also be because "C:\Program Files\dotnet" is not the correct path. This requires you to find the correct installation location of your dotnet and modify it.

    Finally, when your dotnet environment variables are configured correctly, you will find that everything is normal when you re-create a console program.