0

I have a Visual Studio Community Edition 2019 solution with only one project. Whenever I add a source code file to the project, I don't see any changes to git's working tree and therefore it's not added to version control. That causes 2 problems:

  • My peers have to manually add the same source code file to their projects
  • I have to manually add/remove the new source code file when I move between git branches in my dev environment

Searching my git repository for the new file, it only shows up in .vs/<solution_name>/v16/.suo and the .vs directory is in .gitignore. From what I've read at Should I add the Visual Studio .suo and .user files to source control? , this .suo file contains machine-specific configuration and should be ignored by version control, but it seems it also contains the project tree? I see several *.cs files in the .csproj file, but for some reason the files I add to the project tree via the VS UI are not to this file. Am I doing this wrong?

Alan Evangelista
  • 2,888
  • 6
  • 35
  • 45

3 Answers3

1

I saved the project and the .csproj is updated with the new source code file. I got spoiled with web applications that auto-save.

Also, you must close the solution and open it again whenever you change git branches so that Visual Studio realizes that the .csproj file has been updated.

Alan Evangelista
  • 2,888
  • 6
  • 35
  • 45
0

This sounds like you have an overly aggressive .gitignore file in all honesty. I'm not sure what you mean by the 'project tree' being in the .suo, I don't think that's correct, the project file (.csproj) defines which files are included in a project. If you can run git add . from a command prompt under the project directory and you still don't see any local changed files, I'd point to the .gitignore as being the problem.

Tom W
  • 5,108
  • 4
  • 30
  • 52
  • The .csproj file is already in the git repository, but strangely it's not updated when I add/remove files from the project using VS GUI – Alan Evangelista Jun 25 '21 at 08:57
0

When i added/changed exsiting files in the VS solution, the project file (xxx.vcxproj) changed.

An example of added line in this project file can be found in the git diff as

<ClInclude Include=/path/to/added/files />

So I would suggest to double check the .gitignore file and whether your project vcxproj is tracked.

H Cui
  • 1