Creating new solution using "dotnet new sln" in .NET 5.0.201 SDK has wrong/invalid solution version number
See original GitHub issueProblem
When we create new solution using “dotnet new sln” in .NET 5.0.201 SDK has wrong/invalid solution version number in the VisualStudioVersion
. This version is invalid, because there’s no Visual Studio solution has higher version than “16.6..” at this moment (at least in observed 16.9.x)
Reason: this version cannot be used to enforce minimum version of Visual Studio to open.
Steps to reproduce
The steps are:
- Create new solution using
dotnet new sln
. Example:dotnet new sln -n SolutionNET5
- Open the solution file in notepad other text editor
- The version of the VisualStudioVersion is
16.6.30114.105
- Update the MinimumVisualStudioVersion to be the same as VisualStudioVersion
- Open the solution in Visual Studio 2019 16.9.x (error happened in 16.9.0, 16.9.1, 16.9.2)
Full contents after dotnet new sln
is:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.6.30114.105
MinimumVisualStudioVersion = 10.0.40219.1
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
The error after I update the MinimumVisualStudioVersion value to 16.6.30114.105
is:
If I use .NET Core 3.1.406 SDK to create new solution, I have this:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
And this file can always be opened by Visual Studio 16.8.x to 16.9.x without any error, as the MinimumVisualStudioVersion
is still valid solution version.
If I use VS 2019 16.9.2 to create new blank solution, I get this:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31112.23
MinimumVisualStudioVersion = 10.0.40219.1
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {195F37AF-9751-4154-9434-59DB85FFDC3F}
EndGlobalSection
EndGlobal
Update that file by setting MinimumVisualStudioVersion to 16.0.31112.23
, like below:.
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31112.23
MinimumVisualStudioVersion = 16.0.31112.23
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {195F37AF-9751-4154-9434-59DB85FFDC3F}
EndGlobalSection
EndGlobal
Open this file in Visual Studio, and it will open nicely!
Notice the VisualStudioVersion
generated by 16.9.2. It is versioned as 16.0.31112.23
, so VS will not see the version generated by .NET Core 5.0.201 SDK as valid version, because version 16.6.30114.105
is definitely higher than the current generated version of 16.9,2.
Suggestion
Please fix this solution creation version in .NET 5.0.201 SDK!
Issue Analytics
- State:
- Created 2 years ago
- Comments:16 (14 by maintainers)
Top GitHub Comments
As far as I understand it, you have to manually edit the solution file in order to run into a problem here.
I’m also not clear on why you are trying to enforce a minimum VS version in the sln file. I don’t think this is very common. Using a global.json file like the following might do what you want instead:
@marcpopMSFT
About this:
I think we may agree on one point: the version in the solution is incorrect. Therefore, to fix this problem I have just submitted a PR #3007 to revert back to valid solution version number for
release/5.0.2xx
branch. I also strongly suggest that any changes toVisualStudioVersion
andMinimumVisualStudioVersion
must follow these rules:16.0.xxx.xxx
VisualStudioVersion
andMinimumVisualStudioVersion
must not be higher than the current VS 2019 latest RTM version. E.g. today the latest version is 16.9.3, therefore theseVisualStudioVersion
andMinimumVisualStudioVersion
must not be higher than the solution version as generated by 16.9.3.Feel free to correct me and I welcome feedback 🙂