After restoring a project from a solution in VS2017 I can't get access to some of the project source files using the Visual Studio IDE

Belloc 21 Reputation points
2020-08-29T14:36:47.903+00:00

The files are there, in the project directory but I can access only the main file main.cpp. I have two other source files in the project, other.cpp and header.h, but I can't access them using the IDE. I have already tried right clicking:

  1. Source files > Add > Existing items > other.cpp
  2. Header files > Add > Existing items > header.h

But the files don't show up in the solution explorer.

Note 1: The project is building and executing normally.

Note 2: When I restored the files to the project directory from my backup I have only included the three source files mentioned above and the .vcxproj file, as I haven't made the backup for the files .vcxproj.filters and .vcxproj.user, as I thought that would not be necessary.

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,827 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 28,951 Reputation points Microsoft Vendor
    2020-08-31T07:29:01.073+00:00

    Hello Belloc,

    How did you restore the project? I tested on my side but failed to reproduce your issue, so could you share reproduced steps with me? This will be useful for me to check further.

    The Projname.vsxproj.filters file specifies where to put a file that is added to the solution. For example, a .h file is put in the Header Files node. And the Projname.vcxproj.user file stores user-specific properties, for example, debugging and deployment settings. It is recommended to backup all these files but if you don’t use them, you should still be able to see the added .h and .cpp files. Please kindly follow steps below to troubleshoot.

    1. Close all Visual Studio(VS) instances > go to your solution folder and then find the hidden .vs folder > rename or delete it > launch VS and build your project again.
    2. Close VS and reboot your machine then launch VS and create a new C++ project, after that please try to add the existed .h and .cpp files to the newer project and build again.(Maybe you can also try to add a new .h or .cpp file and copy the contents from old files to new files)
    3. Please click the “Show All Files” button and check if the specified .h and .cpp files are shown in Solution Explorer, if you can see them, select them and change the Included In Project property from False to True.

    21429-screenshot1.png

    1. Besides, please also rename(or delete) every subfolders named ComponentModelCache under this directory C:\Users\[user name]\AppData\Local\Microsoft\VisualStudio\15.0_XXXXX. After that build your application again.

    Sincerely,
    Tianyu

    0 comments No comments