13

When attempting to add back existing projects to a Visual Studio 2015 solution, VS gives the following error message. I have verified I have not already added a reference to the project I am trying to add. Is there a settings or cache file I need to delete or cleanup somewhere?

An equivalent project (a project with the same global properties and tools version) is already present in the project collection, with the path "D:\My\Path\MyProject.csproj". To load an equivalent into this project collection, unload this project first.

Adam
  • 4,590
  • 10
  • 51
  • 84

12 Answers12

16

Simply "Clean Solution" worked for me.

Pep Jorge
  • 276
  • 2
  • 4
  • 8
    I had to do this, and also restart Visual Studio. Odd – 8bitcartridge Jun 29 '16 at 21:09
  • 5
    Clean, then force reload of the project (right click) worked for me. I also sacrificed a small stuffed animal , so that may have helped. – Ian Vink Aug 24 '16 at 21:24
  • 2
    Manual clean (Deleting all bin / obj folders manually from the solution) worked for me – Sharique Abdullah Oct 14 '16 at 19:02
  • 2
    Clean itself did not work, cleaning the workspace with `tf reconcile /clean /recursive .` itself did not work either. I had to exit Visual Studio and restart in addition to fix the issue. – uceumern Jan 10 '17 at 09:33
9

This happened to me after messing around with my project files with an external editor. I was able to solve the problem by exiting from VS and also killing, VsHub.exe.

It seems that VsHub.exe caches some portion of the project and becomes confused or out-of-sync with VS.

centis
  • 91
  • 2
  • 2
  • Thanks. It was complaining that a `.filters` file had conflicting references but that `.filters` file did not exist. – Okkenator Mar 24 '20 at 14:29
5

I invoked it through code.

This fixed it for me:

Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.LoadedProjects.FirstOrDefault(d => d.FullPath == projectFilePath) ??
                Microsoft.Build.Evaluation.Project.FromFile(projectFilePath, new ProjectOptions())
Dbl
  • 5,634
  • 3
  • 41
  • 66
2

This link provided me with a simple prophylactic, one much less drastic than running {VSpath}\devenv.exe /resetuserdata

I found that by adding a Filter to the project (even though I didn't particularly need one) I could force VS2015 to create a .vcxproj.filters file. Once in place, I stopped seeing the problem.

BTW, in my case the problem was triggered by unloading the project, making tricky changes in the .vcxproj file (stuff involving [MSBuild] arithmetic on property values), then trying to reload the project, and having that fail due to syntax errors. Fixing the errors, removing/re-adding the project, etc. did not work. The 'already present' bug persisted.

NoBrassRing
  • 483
  • 7
  • 15
1

I get this frequently when switching branches with git. I find that if I "touch ZFSin.vcxproj.filters" - (the projects filters file) I can then right-click the failed-to-load project and "reload". No Clean-project, nor restart VS2017. (Touch is a command that just updates the timestamps on a file).

lundman
  • 1,616
  • 13
  • 25
1

In my case, the project only had a x64 platform configuration, not a Win32 platform configuration. Strangely enough the solution did have the Win32 platform configuration and for some reason Win32 was the current platform configuration.

After changing to x64 I could load the project again without problems. I also removed the Win32 platform configuration just to make sure.

Brandlingo
  • 2,817
  • 1
  • 22
  • 34
0

Still not sure what causes this to happen but it seems adding the dependent projects in reverse order allowed me to add all of my projects back in. So add all child projects first and then add the parent projects they depend on. The order they were added back into the solution may have caused the flakiness.

Adam
  • 4,590
  • 10
  • 51
  • 84
0

This happened to me after a bluescreen. The following seemed to fix it:

  1. Start VS2015 cmd prompt.
  2. Run "devenv /resetuserdata"
Jay Borseth
  • 1,894
  • 20
  • 29
  • 8
    Careful! This is a rather drastic approach, because it will reset all your Visual Studio settings including any AddIns you may have installed. – uceumern Jun 22 '16 at 12:41
  • 2
    OMG what did I just do?!? – Dmitri Nesteruk Jan 30 '17 at 12:29
  • This worked, but also deleted all my plugins and custom settings. I wish VS didn't try to cache so many things in so many hidden places. – JamesFaix Apr 10 '18 at 15:40
  • I've had to do this twice now in the past week when trying to upgrade a project from Framework to Standard. A project that depends on the upgraded project will give this error until I delete my user cache. Deleting the `.vs` folder, rebooting, cleaning solution, and manually deleting `bin` and `obj` folders did nothing in my case. – JamesFaix Apr 18 '18 at 12:51
0

Windows reboot fixed this problem for me. After reboot Visual Studio does not show such strange error message.

Andrey Epifantsev
  • 976
  • 1
  • 11
  • 27
0

In my case I saw this error when I was doing the following:

I was including/importing 3.vcxproj inside 2.vcxproj and 2.vcxproj was included inside 1.vcxproj.

The path to 3.vcxproj inside 2.vcxproj was wrong and that gave me above error.

Corrected the path and error went away. Not sure how filters are related.

S__J
  • 11
  • 1
0

I had this problem when the solution was using environment variables in project paths and other paths. I think it was expecting to find %var1%\proj.vcxproj and %var2%\proj.vcxproj , but %var1% and %var2% had the same value.

cowlinator
  • 7,195
  • 6
  • 41
  • 61
0

This is occurring in VS 2022 as well. None of the solutions posted here worked in my case.

The fix for me: Delete the profile and create a new profile. {PROJECT_DIR}\Properties\PublishProfile\{YOUR_PROFILE}

szMuzzyA
  • 136
  • 13