question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Creating new solution using "dotnet new sln" in .NET 5.0.201 SDK has wrong/invalid solution version number

See original GitHub issue

Problem

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:

  1. Create new solution using dotnet new sln. Example: dotnet new sln -n SolutionNET5
  2. Open the solution file in notepad other text editor
  3. The version of the VisualStudioVersion is 16.6.30114.105
  4. Update the MinimumVisualStudioVersion to be the same as VisualStudioVersion
  5. 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:

image

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:closed
  • Created 2 years ago
  • Comments:16 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
dsplaistedcommented, Apr 6, 2021

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:

{
  "sdk": {
    "version": "5.0.100",
    "rollForward": "latestMajor"
  }
}
0reactions
eriawancommented, Apr 8, 2021

@marcpopMSFT

About this:

The minor version number should always be specified as zero in the solution file. The correct value for 16.6 for example would be 16.0.30114.105 which is the build number of 16.6.0 per the shipready internal tool.

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 to VisualStudioVersion and MinimumVisualStudioVersion must follow these rules:

  1. Obey current versioning schema of VS 2019: using pattern of 16.0.xxx.xxx
  2. The version number for both VisualStudioVersion and MinimumVisualStudioVersion must not be higher than the current VS 2019 latest RTM version. E.g. today the latest version is 16.9.3, therefore these VisualStudioVersion and MinimumVisualStudioVersion must not be higher than the solution version as generated by 16.9.3.

Feel free to correct me and I welcome feedback 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating new solution using "dotnet new sln" in .NET 5.0. ...
Problem When we create new solution using "dotnet new sln" in .NET 5.0.201 SDK has wrong/invalid solution version number in the ...
Read more >
dotnet sln command - .NET CLI
The dotnet-sln command provides a convenient option to add, remove, and list projects in a solution file.
Read more >
How to create Solution file with dotnet core CLI
AS I've seen it's a two step operation which consists of: 1 - Creating the Solution file with "dotnet new sln --name mysolution.sln"...
Read more >
Support for the Upcoming .NET SDK 6.0
NET Core SDK for Solution' dialog box is shown: I changed the SDK version to 5.0, like this, and clicked OK: I then...
Read more >
Building .NET projects using the Microsoft.Build.Traversal ...
In this post, I describe how to use the Microsoft.Build.Traversal MSBuild SDK to build a solution.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found