37

I have a solution which uses Solution Folders to split out the projects. In the Visual Studio IDE, the solution builds fine.

However when running the build using MSBuild from the command line, I get the following error:-

Solution file error MSB5023: Error parsing the nested project section in solution file. A project with the GUID "{Some Project GUID}" is listed as being nested under project "{Some Solution Folder Project GUID}", but does not exist in the solution.

Now I've checked these two GUIDs over, and they exist, one as a project, the other as the solution folder that the project is nested under. There shouldn't be any problem.

Does anyone have a way to resolve this?

Liam
  • 27,717
  • 28
  • 128
  • 190
Sean Holmesby
  • 2,135
  • 3
  • 23
  • 34
  • Note a dupe, but has very similar fixes to the problem: https://stackoverflow.com/questions/6599966/team-foundation-server-2010-msbuild-error-parsing-the-nested-project-section – StayOnTarget May 17 '19 at 14:12

7 Answers7

90

I faced the same issue and managed to sort out:

  1. Opened .sln in NotePad and found Guids
  2. One of my projects wasn't closed ("EndProject" was missed)

Cheers, hope this can help anyone

Denis Evseev
  • 1,660
  • 1
  • 18
  • 33
  • 5
    This was the solution for me. After a git conflict I had a malformed sln file lacking an `EndProject` line – gvdm Dec 12 '18 at 23:18
  • 1
    I had this problem after resolving a git conflict. I found concatenation of "EndProjectProject" in .sln and just added the break line to split it. – Artem Kolokoltsev Jul 14 '21 at 14:27
  • 1
    While my issue wasn't a closing EndProject tag, this helped! Turned out my solution was trying to add a ProjectSection that no longer existed. I moved the ProjectSection and that resolved my issue. – bluefox Jan 31 '23 at 19:19
27

Or you can add a new file to the solution and save. This should rebuild the solution. After confirming the build is working fine, the file can be safely removed and saved.

Pon Saravanan
  • 525
  • 5
  • 12
  • 1
    I added a solution item and saved the solution. I'm not sure the same thing will happen if you add a file to a project instead. – Daniel Gabriel Dec 06 '18 at 17:40
  • 2
    It created a "Solution Items" folder when I did this (which I later removed). This procedure corrected the error, which turned out to be a missing "EndProject" line. – StayOnTarget May 17 '19 at 14:10
  • 1
    For me this also helped. The problem wasn't with the missing `EndProject` tho, there was a leftover guid that should have been removed from .sln – Mr. Blond Apr 20 '20 at 14:21
  • Ohh this is briliant thank you. |Git merge messed up my sln I had no clue what to do.. just did what you said.. added a project. save.. boom fixed it up (stoopid thing is in vs it build in dotnet cli it didnt) doh – Piotr Kula Jun 15 '22 at 16:12
6

It's probably answered already but I'd mention in steps to make it even easier to do.

Steps to fix:

  1. Add a new dummy project to the solution
  2. Use Save All button to update the solution
  3. Remove the dummy project added earlier & build. And it's fixed
  4. Additionally if you are using source control, compare the updated .sln file with old one to know the missing changes.
Dash
  • 804
  • 1
  • 9
  • 16
4

It is possible you may also have an issue where the line could have gotten in here with a merge conflict where it wasn't deleted when a project was deleted. If you can't find any other references in your project with a global search of the GUID, try deleting the line in the .sln file and rebuilding.

daniel.caspers
  • 1,660
  • 1
  • 18
  • 22
1

Due to a merge conflict, my solution file was trying to stick two projects in a solution folder that didn't exist anymore. the NestedProjects section near the bottom mentioned a Guid that was removed from the Project enumeration at the top.

increddibelly
  • 1,221
  • 1
  • 15
  • 25
1

There is a possibility that it is a merge conflict problem that changed the .sln file, confirm that it is not the case by opening in your favorite text editor and checking if there is any conflict markup.

0

I created a blank solution and add my csproj. After this, my YAML in Azure DevOps can build the application

Felipe Augusto
  • 1,341
  • 1
  • 16
  • 18