Can't build C# project in my Visual Studio?

Musfiqur Nabil 6 Reputation points
2023-01-02T16:25:37.35+00:00

I am trying to build a C# project but I don't see any build option in my Visual Studio IDE. version 2019.

275400-problem.png

Developer technologies | C#
0 comments No comments
{count} vote

4 answers

Sort by: Most helpful
  1. Michael Taylor 60,161 Reputation points
    2023-01-02T16:39:08.897+00:00

    You have a solution but no project. A solution is a virtual collection of projects. When you build, debug, etc then it is recursively applied to the projects in the solution. Since you have no projects there is nothing to do.

    To create a C# project you should select File \ New \ Project or use the Start Window and create a new project. In the Create a new project dialog you would select the appropriate C# project template. Given your screenshot I'm going to recommend Console App, filtered to C#, then click Next.

    275473-image.png

    If you already have a solution open then the project will be automatically added to the open solution. Otherwise it'll ask you to create a solution as well (which is the virtual collection of projects mentioned earlier) along with the location to store the solution and projects.

    275459-image.png

    Then you'll walk through a quick wizard to select some basic options like target framework. Once you're done VS will show the project under the solution. It will also auto-create the initial program.cs where you will be placing your code.

    275475-image.png

    You can create additional C# source files in this project and they will be automatically included in the compilation as well. If you want to create additional projects (which are just deployable units) then you can right click the solution and select Add \ New Project to add as many more projects as you want. Note that each project compiles in isolation so if you want to share code then you have additional work to do. Additionally the IDE compiles all the projects so you need to ensure all projects compile. If you want to remove a project then you can right click and remove it.

    On the file system side, a solution is created in a folder which matches the solution name. Within that solution folder VS will create a subfolder for each project. Each project resides in its own subfolder to avoid conflicts. When you are "moving" projects you should be copying the entire solution folder structure.

    1 person found this answer helpful.
    0 comments No comments

  2. Castorix31 90,681 Reputation points
    2023-01-02T16:35:13.043+00:00

    Open a c# project template, like :

    275474-console-framework.jpg

    0 comments No comments

  3. Viorel 122.6K Reputation points
    2023-01-02T16:37:33.3+00:00

    It seems that you did not create any project yet.

    Try creating a new project according to tutorial: https://learn.microsoft.com/en-us/visualstudio/get-started/csharp/tutorial-console?view=vs-2019. (Maybe start a new instance of Visual Studio).

    0 comments No comments

  4. Karen Payne MVP 35,586 Reputation points Volunteer Moderator
    2023-01-02T16:40:22.483+00:00

    Your solution has zero projects, you need to add the project to the solution.

    See Microsoft documentation Add an Existing Project to a Solution and Create a new project in Visual Studio

    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.