No build menu in Visual Studio when opening an existing cpp file
Asked Answered
B

2

14

I am new to Visual Studio. I just followed a tutorial and successfully wrote and ran a simple program. But after I closed Visual Studio and double click the cpp file I just wrote. I can't find the build menu in the Visual Studio. Could anyone tell me how to open and run the existing cpp file? I need to do some debug and don't want to begin a new project and copy the code again and again. Thanks!

Badillo answered 19/1, 2016 at 2:28 Comment(0)
C
11

You need to open more than the .cpp file alone.

Make sure you open the whole project or solution (File/Open/Project - .sln, .vcxproj, .vcproj). Double clicking on a .cpp file will open that file only.

Then you should be able to build the project (or hit Ctrl-F5).

Chandra answered 19/1, 2016 at 2:32 Comment(1)
To be more precise, open the file that ends in .sln or in .vcxproj, they are the project file that instruct VS how to build your program and what files it needsCrossopterygian
A
3

I faced this problem suddenly in vs 2022 in one of my projects c#. When I opened other project it looks ok and the build menu is available.

When inspecting the project, I found by accident that the project is opened as folder (open folder). I closed the project then select 'open project or Solution' and every thing is ok.

So the root issue is that project is opened as folder.

Atalanta answered 13/5, 2023 at 14:41 Comment(2)
Hello @Atalanta could you take a look to this question please? I've some difficulties to open the project because there isn't a sln or other files recognized by VS as a project. #77141323Ingate
Hello @GennaroArguzzi, I answered the question here. Let me know if this can resolve your issueAtalanta

© 2022 - 2024 — McMap. All rights reserved.