Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.SLNX format support #10794

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Conversation

surayya-MS
Copy link
Member

@surayya-MS surayya-MS commented Oct 10, 2024

Fixes #10266

Context

We currently use our own parser SolutionFile.Parse() to parse .sln files in order to build them.
In this PR I intergrate the new package Microsoft.VisualStudio.SolutionPersistence to parse the new format .slnx files.

Key differences in the SolutionFile from the package's SolutionModel:

  1. ProjectsInOrder and ProjectsByGuid no loner include solution folders because they are saved separately (in the package SolutionModel.SolutionProjects and SolutionModel.SolutionFolders)
  2. SolutionConfigurations are not available in the SolutionModel, instead there are BuildTypes and Platforms. Since SolutionConfigurations are used in SolutionGenerator a lot, I needed SolutionConfigurations represented accurately. Combination of SoutionModel's BuildTypes and Platforms might be redundant, so I collect Solution configurations from each project's configurations.

Changes Made

Testing

  1. Added tests in SolutionFile_Tests that cover .slnx cases
  2. Added SolutionFile_NewParser_Tests with only one test for parse website properties as it was not possible to do that in SolutionFile_Tests because AspNetConfigurations is internal.
  3. Tested manually as well.

Notes

Copy link

@ssg ssg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose explicit matching of filename extensions.

src/MSBuild/XMake.cs Show resolved Hide resolved
@kasperk81
Copy link
Contributor

@rainersigwald
Copy link
Member

@kasperk81 we're going to use that deserializer in a follow-up PR. We're trying to make this PR the "minimum risk for potential backport to 9.0.1xx SDK" change, so keeping the existing sln behavior.

Copy link
Member

@JanKrivanek JanKrivanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks as expected.

But I did just a quick pass - will go more in depth tomorrow

src/Build/Construction/Solution/SolutionFile.cs Outdated Show resolved Hide resolved
@@ -76,4 +76,8 @@
<FileVersion>$(VersionPrefix).$(FileVersion.Split('.')[3])</FileVersion>
</PropertyGroup>
</Target>
<!-- SolutionPersistence -->
<PropertyGroup>
<MicrosoftVisualStudioSolutionPersistenceVersion>1.0.4</MicrosoftVisualStudioSolutionPersistenceVersion>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not on nuget.org yet so we'll have to either wait for that (@richardstanton?) or get a more manual push going.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/microsoft/vs-solutionpersistence/blob/main/README.md has a badge linked to nuget.org, but currently it's returning 404. dotnet nuget push missing somewhere :)

src/Build/Microsoft.Build.csproj Outdated Show resolved Hide resolved
@@ -76,4 +76,8 @@
<FileVersion>$(VersionPrefix).$(FileVersion.Split('.')[3])</FileVersion>
</PropertyGroup>
</Target>
<!-- SolutionPersistence -->
<PropertyGroup>
<MicrosoftVisualStudioSolutionPersistenceVersion>1.0.4</MicrosoftVisualStudioSolutionPersistenceVersion>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not on nuget.org yet so we'll have to either wait for that (@richardstanton?) or get a more manual push going.

src/MSBuild.UnitTests/XMake_Tests.cs Outdated Show resolved Hide resolved
src/Build.UnitTests/Construction/SolutionFilter_Tests.cs Outdated Show resolved Hide resolved
src/Build.OM.UnitTests/Construction/SolutionFile_Tests.cs Outdated Show resolved Hide resolved
src/Build/Construction/Solution/SolutionFile.cs Outdated Show resolved Hide resolved
src/Build/Construction/Solution/SolutionFile.cs Outdated Show resolved Hide resolved
ProjectFileErrorUtilities.ThrowInvalidProjectFile(
new BuildEventFileInfo(FullPath),
$"InvalidProjectFile",
$"No solution serializer was found for {FullPath}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider a new localized string "UnrecognizedSolutionFormat" or similar. Though actually that makes the backport hard so maybe don't consider it too hard.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll do this in the follow-up PR then

Copy link
Member

@JanKrivanek JanKrivanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

src/Build/Construction/Solution/SolutionFile.cs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Support building the new Visual Studio solution file format (.slnx)
6 participants