183

Everthing below is made in VS2019, using .NET Framework 4.7 and NUnit + NUnit3TestAdapter

I created an assembly called Exitus.Tests, and added a few unit tests. However, do to some issues with Nuget, that I could not solve, I made another project called Exitus.UnitTests and removed the once file I had in the old project (including changing the namespace).

Now the new test project showed op correctly in the explorer, but a "ghost" of the old project remained:

Visual Studio test explorer

If I try to run the test, the output window shows the following error:

System.InvalidOperationException: The following TestContainer was not found 'C:\Users\xxx\Source\Repositories\Expire\Exitus.Tests\bin\Debug\Exitus.Tests.dll' at Microsoft.VisualStudio.TestWindow.Client.TestContainer.TestContainerProvider.d__46.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.TestWindow.Controller.TestContainerConfigurationQueryByTestsBase.d__6.MoveNext() (...)

The stack trace is a lot longer, but the curious thing is the second line, stating that it could not find the test container at \Exitus.Tests\bin\Debug\Exitus.Tests.dll. This is the name of the old test project, which I removed and deleted. I have searched my entire project for the term Exitus.Tests and it returns no results.

Is there anyway to forcefully remove this 'ghost' project?

1

5 Answers 5

386
  1. Close Visual Studio.
  2. Delete the *.testlog files in: solutionfolder\.vs\solution name\v16\TestStore\number.
8
  • 3
    After much feedback, I have decided to change this to the acceptet answer. I still used Alex B.'s answer, which works fine as long as you don have critical files in your git repository, which may not tracked. Jan 2, 2020 at 19:57
  • 15
    .vs is a hidden directory. Make sure to set your file explorer to see hidden directories
    – citronas
    Jan 7, 2020 at 13:45
  • 4
    99% of visual studio errors are solved by removing magic hidden files in the .vs folder, or the windows temp / roaming / local folder. :C
    – filescraps
    Feb 14, 2020 at 15:48
  • 5
    I asked internally about this. Apparently the problem's fixed in 16.5. Feb 18, 2020 at 22:06
  • I did not get it to work with this answer. I had to use Alex B's answer. Mar 9, 2020 at 13:41
22

I faced the same issue right now. A cleanup helped. As I had cleanup issues with VS in the last time (some DB-lock prevents a real cleanup to happen), my working cleanup was this way:

  1. Close VS.
  2. Git Bash in solution folder: git clean -xfd

Probably it helps.

6
  • 3
    That worked, thank you very much. It looks like your first post, if that is the case, I must say that it's once heck of an entrance to make :-) Dec 18, 2019 at 12:59
  • I saw the "Uknown Project" in the test explorer results a few times when I moved tests between test DLLs with the XUnit test runner. I found it was sufficient to delete the .vs folder which was in the same folder as my solution file. Dec 18, 2019 at 13:13
  • 9
    This answer will remove anything that isn't in source control, so if you don't check in things like launchSettings.json, you may want to use pwretmo's answer instead.
    – Sean
    Dec 20, 2019 at 14:32
  • 4
    @pwretmo answer is a safer and more direct answer to the specific problem.
    – snowcode
    Dec 23, 2019 at 4:03
  • 3
    The community has spoken. I have changed the accepted answer, to help others the best possible way. This answer was still fine for me, but I get the point that it can introduce certain risks. I am still very grateful for the help though :-). Jan 2, 2020 at 19:59
1

Neither of these solutions worked for me. I was able to get the test explorer working by closing visual studio and deleting the ".vs" folder. Then reopen the solution and let it rebuild it.

1

According to the Visual Studio developer community (found by going to the Help menu and selecting Feedback), an update to Visual Studio to version 16.5.5 will resolve the issue. FYI: They released this in February 2020

I can confirm it works (I was on VS 16.4.6)

0

Steps as below

  1. Close Visual Studio

  2. Go to the project folder

  3. Find the ".vs" folder. (Make sure you are also checking hidden item)

  4. Delete ".vs" folder.

  5. Good to go, Open visual studio, build and run project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.