0

I have created an NUnit Test Project in my Visual Studio Solution. I have gotten the project to compile fine and I am able to detect and run the tests in the Test Explorer, but for some reason, the project itself is ignored by git:

enter image description here

Typically when this happens with a file, I just right click > Source Control > Add Ignored File to Source Control... But doing that in this case does not work. I just get the following message in the output window:

File not found in any active repository: C:\Users\[myUsername]\.nuget\packages\nunit3testadapter\3.13.0\build\netcoreapp1.0\NUnit3.TestAdapter.pdb

This file does exist, but it would not make sense for me to add it to source control since it is at a location specific to my local user. I have tried moving the nuget package to the same directory where other nuget packages are located and working fine, adding a reference manually, but that doesn't fix it either.

The Nuget Package Manager shows both the NUnit as well as the NUnit3TestAdapter packages have installed their latest versions to the project successfully:

enter image description here

You can also see the tests being detected and running fine in the test explorer as I mentioned before.

How can I add this project to git?

Reddy
  • 481
  • 1
  • 7
  • 20
  • Where is the test project on disk? It looks to me like you created the project outside of the solution root of your git repo. – Rob Prouse Jun 11 '19 at 23:59
  • The NUnit project is in the same location as the other projects you can see in my first screenshot, and those ones are checked-in to git with no problems. (As indicated by the padlock icon) The root of the repository is one level above the solution. (Located on my D: drive) – Reddy Jun 12 '19 at 01:14

1 Answers1

1

Your question is effectively a duplicate of how to check why a file is being ignored by git.

Go to a command prompt where you have git available, cd to your test project directory and run git show-ignore -v *.csproj. It should output the .gitignore file and line number that matches the rule that is preventing your test project from being added. If this command doesn't work, look up other answers on how to check why a file is being ignored.

zivkan
  • 12,793
  • 2
  • 34
  • 51
  • I couldn't get that command to work, but I did check the .gitignore file. It was apparently ignoring the entire directory the solution was in so I removed that. I am still puzzled as to why I was able to add the other projects to git but not this one though, I also had to restart Visual Studio after updating for it to work. I'll mark this as the answer since .gitignore was the source of the issue. Thanks! – Reddy Jun 12 '19 at 19:05