Detect Corrupt Solution File in Dotnet Sln Add#28811
Detect Corrupt Solution File in Dotnet Sln Add#28811nagilson merged 3 commits intodotnet:release/7.0.2xxfrom
Conversation
|
Just curious, MSBuild has its own solution parser code, is there any relationship/sharing? |
I don't think this code is shared by MSBuild, I couldn't find something like it. And I think this code is basically doing what Mono does. That's a good question though. cc @rainersigwald to potentially add his thoughts. |
there are also https://github.com/microsoft/slngen/blob/main/src/Microsoft.VisualStudio.SlnGen/SlnFile.cs and https://github.com/mono/monodevelop/blob/main/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/SlnFile.cs |
rainersigwald
left a comment
There was a problem hiding this comment.
Just curious, MSBuild has its own solution parser code, is there any relationship/sharing?
I don't think this code is shared by MSBuild, I couldn't find something like it. And I think this code is basically doing what Mono does. That's a good question though.
This is how MSBuild tolerates projects malformed in this specific way:
The MSBuild SolutionFile object is read-only so probably not useful as-is to the CLI, since you'll want to mutate the solution.
It is of course unfortunate that we have this duplication all over everything. I'd really like a public, open-source solution API from the Visual Studio team, but that's low on their priority list at the moment.
|
@baronfel PTAL at the error again when available, Marc wanted your approval before signing off on this |
baronfel
left a comment
There was a problem hiding this comment.
Sorry aout the delay! Message reads well and is actionable 👍
Hey it actually happened :) |
Resolves #28155 (comment), see for more context.
A solution file can contain solution folders which aren't actually on disk and are just a solution file construct. These folders are written via child -> parent hashtable mappings in a preSolution configuration. During manual editing, merge conflicts, and or external editors, these mappings may become invalid. At the same time, solution project folders may mistakenly not include
EndProjecttags. Visual Studio accounts for these invalid files and lets the user get away with it, and upon saving can repair the solution file. For us and Mono, we more strictly enforce the file format and this adds an error to describe what's wrong with the file and how to fix it.Before:
After:
