Reputation: 121
I have an issue in some Visual Studio C# projects, when I commit changes in a c# project. If I added a new file to the project, this information is added to the csprj-file of the project. I do a git commit and the change of the csprj-file is in this commit, but in the csprj-file is still listed list of not committed changes in git. I must do a second commit to commit the csprj-file. The csprj-file is included in both commits and has the same content. I have the same behavior, if i do the commits with git client like TortoiseGit instead of using the Team Explorer in Visual Studio.
What could I do to repair this? I use Visual Studio 2019 Version 16.4.3
Upvotes: 4
Views: 1899
Reputation: 121
Thank you for your help.
I looked at the problem with a colleague again and we found the cause for the problem. A few month ago, I renamed the namespace and the project name from "xxx.ICS.Datalayer" to "xxx.Ics.Datalayer".
After this in my visual studio solution on my Windows computer I had one project file: "xxx.Ics.Datalayer.csproj", but today we realized that in the git-repository we have two files "xxx.Ics.Datalayer.csproj" and ""xxx.ICS.Datalayer.csproj". I did not recognize that the first commit was for the change with the old filename and the second commit was for the new filename.
To fix the problem, I saved the csproj file and then deleted it. The commit with the deletion then deleted both files in the git repository. Afterwards I could insert the csproj file into the Visual Studio Solution again.
Upvotes: 2
Reputation: 1327524
You should be able, before your first commit, to add the modified csproj as well.
(Typically, right-click + stage, as in this documentation)
That way, one commit is enough to be record the new file and the modified .csproj
project file.
Upvotes: 0