Skip to content

Commit

Permalink
Permit comments and trailing commas in solution filter files (#6346)
Browse files Browse the repository at this point in the history
  • Loading branch information
Forgind committed Apr 15, 2021
1 parent 077ef33 commit 478f12f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Expand Up @@ -152,9 +152,11 @@ public void SolutionFilterFiltersProjects()
@"
{
""solution"": {
// I'm a comment
""path"": "".\\SimpleProject\\SimpleProject.sln"",
""projects"": [
""SimpleProject\\SimpleProject.csproj""
/* ""..\\ClassLibrary\\ClassLibrary\\ClassLibrary.csproj"", */
""SimpleProject\\SimpleProject.csproj"",
]
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/Build/Construction/Solution/SolutionFile.cs
Expand Up @@ -415,7 +415,9 @@ internal static string ParseSolutionFromSolutionFilter(string solutionFilterFile
{
try
{
JsonDocument text = JsonDocument.Parse(File.ReadAllText(solutionFilterFile));
// This is to align MSBuild with what VS permits in loading solution filter files. These are not in them by default but can be added manually.
JsonDocumentOptions options = new JsonDocumentOptions() { AllowTrailingCommas = true, CommentHandling = JsonCommentHandling.Skip };
JsonDocument text = JsonDocument.Parse(File.ReadAllText(solutionFilterFile), options);
solution = text.RootElement.GetProperty("solution");
return FileUtilities.GetFullPath(solution.GetProperty("path").GetString(), Path.GetDirectoryName(solutionFilterFile));
}
Expand Down

0 comments on commit 478f12f

Please sign in to comment.