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

MSBuild skips building a project in the solution at all due to overly permissive parsing of the solution file. #5027

Closed
MarkKharitonov opened this issue Jan 3, 2020 · 2 comments · Fixed by #5808
Assignees
Labels
Area: Solution (.sln) Issues related to parsing .sln files or building solutions triaged
Milestone

Comments

@MarkKharitonov
Copy link

MarkKharitonov commented Jan 3, 2020

Steps to reproduce

Solution file


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29509.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp3", "ConsoleApp3\ConsoleApp3.csproj", "{D5F72F13-B7F0-4F67-BDEE-F041D02DC618}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{3DB043B3-7FE4-40F1-A9BA-8987FB252DE7}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{D5F72F13-B7F0-4F67-BDEE-F041D02DC618}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{D5F72F13-B7F0-4F67-BDEE-F041D02DC618}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{D5F72F13-B7F0-4F67-BDEE-F041D02DC618}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{D5F72F13-B7F0-4F67-BDEE-F041D02DC618}.Release|Any CPU.Build.0 = Release|Any CPU
		{3DB043B3-7FE4-40F1-A9BA-8987FB252DE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{3DB043B3-7FE4-40F1-A9BA-8987FB252DE7}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{3DB043B3-7FE4-40F1-A9BA-8987FB252DE7}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{3DB043B3-7FE4-40F1-A9BA-8987FB252DE7}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {A016638C-EF8F-45E3-9A96-32F3E2378AED}
	EndGlobalSection
EndGlobal

Notice the project line for ConsoleApp3 misses the EndProject line. But the parser does not fail - instead it skips over the project line for ConsoleApp1 and uses its EndProject to terminate the project line for ConsoleApp3.

You can reproduce it trivially - create a solution with two projects and then delete the first EndProject.

Of course, nobody does it on purpose. But it has happened for us because of a bad Git merge.

Expected behaviour

Building the solution on the command line with msbuild fails, because of the malformed solution file.

Actual behaviour

The project ConsoleApp1 simply not built.

In our case this was a unit test project, so the fact it was not built was not caught right away, because:

  1. The solution overall cleanly builds and runs (unit test projects have no effect here)
  2. The project in question does build cleanly inside Visual Studio, because the latter does not parse the solution file using msbuild.

P.S.
It would have been nice, though, if the VS IDE warned about the malformed solution file.

@rainersigwald rainersigwald added the Area: Solution (.sln) Issues related to parsing .sln files or building solutions label Jan 6, 2020
@rainersigwald
Copy link
Member

So the Visual Studio IDE experience is as though it silently added an EndProject when encountering a new Project(... line? That's unfortunate, but MSBuild should match the VS behavior.

@rainersigwald rainersigwald added the help wanted Issues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim. label Jan 6, 2020
@rainersigwald rainersigwald added this to the Backlog milestone Jan 6, 2020
@BartoszKlonowski
Copy link
Contributor

@rainersigwald I would like to work on this issue, so please assign this item to me.

@benvillalobos benvillalobos removed the help wanted Issues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim. label Oct 14, 2020
@AR-May AR-May added the triaged label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Solution (.sln) Issues related to parsing .sln files or building solutions triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants