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

Solution parser fails when projects have similar names #3019

Closed
rainersigwald opened this issue Feb 22, 2018 · 9 comments
Closed

Solution parser fails when projects have similar names #3019

rainersigwald opened this issue Feb 22, 2018 · 9 comments
Labels
Area: Solution (.sln) Issues related to parsing .sln files or building solutions bug triaged

Comments

@rainersigwald
Copy link
Member

Steps to reproduce

Attempt to build this solution:

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2010
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Project.Named.With.Dots", "Project.Named.With.Dots.csproj", "{FC2889D9-6050-4D2E-B022-979CCFEEAAAC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Project_Named_With_Dots", "Project_Named_With_Dots.csproj", "{ED30D4A3-1214-410B-82BB-B61E5A9D05CA}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{FC2889D9-6050-4D2E-B022-979CCFEEAAAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{FC2889D9-6050-4D2E-B022-979CCFEEAAAC}.Release|Any CPU.Build.0 = Release|Any CPU
		{ED30D4A3-1214-410B-82BB-B61E5A9D05CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{ED30D4A3-1214-410B-82BB-B61E5A9D05CA}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {C038ED6B-BFC1-4E50-AE2E-7993F6883D7F}
	EndGlobalSection
EndGlobal

Expected behavior

Successful build.

Actual behavior

Build FAILED.

         C:\Users\raines\source\repos\SolutionWithConflictingNames\SolutionWithConflictingNames.sln : Solution file error MSB5004: The solution file has two projects named "Project_Named_With_Dots".

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.05

Environment data

msbuild /version output: Microsoft (R) Build Engine version 15.5.180.51428 for .NET Framework

(Related to #530 but different since the solution is entirely valid here and the conflict is within MSBuild.)

@rainersigwald rainersigwald added bug Area: Solution (.sln) Issues related to parsing .sln files or building solutions labels Feb 22, 2018
@ProfFan
Copy link

ProfFan commented Dec 31, 2019

@rainersigwald Jumping in here... Our project is blocked by this as we rely on AppVeyor to do CI and CMake generates project names exactly like this... Do you have a workaround on this issue? Many thanks!

@joseotavioq
Copy link
Contributor

joseotavioq commented Apr 26, 2020

@rainersigwald I can see 2 solutions here. Based on your experience, which one is better and has less impact? (or if you have another one)

  1. Remove the char '.' from the s_charsToCleanse char[] attribute (line of code);
  2. Change the value of cleanCharacter attribute to another character, like pipe '|' (line of code)

@rainersigwald
Copy link
Member Author

rainersigwald commented Apr 28, 2020

@joseotavioq Unfortunately both have compat impact: either way we'd break people's build command lines that build on the current .->_ behavior.

The only way I can think of that doesn't have that impact is to detect collisions caused solely by normalization and normalize in a different way somehow.

@joseotavioq
Copy link
Contributor

@rainersigwald I am trying to figure out a solution to this issue.

I am thinking about generating the unique name concatenating the repeated normalized project name with the project Guid.

For example:

  • Project_Named_With_Dots_{FC2889D9-6050-4D2E-B022-979CCFEEAAAC}
  • Project_Named_With_Dots

What do you think about it?

However, when I was thinking about this solution, the following case came to me:

We have 2 projects with the same name that are going to be normalized.

Project('{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}') = 'Project.Named.With.Dots', 'Project.Named.With.Dots.csproj', '{FC2889D9-6050-4D2E-B022-979CCFEEAAAC}'
EndProject
Project('{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}') = 'Project_Named_With_Dots', 'Project_Named_With_Dots.csproj', '{ED30D4A3-1214-410B-82BB-B61E5A9D05CA}'
EndProject
Project('{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}') = 'Project.Named.With.Dots', 'Project.Named.With.Dots.csproj', '{6185CC21-BE89-448A-B3C0-D1C27112E595}'
EndProject

What should we do in this case?

  1. Normalize both, as below, and continue without throwing an exception.
  • Project_Named_With_Dots_{FC2889D9-6050-4D2E-B022-979CCFEEAAAC}
  • Project_Named_With_Dots
  • Project_Named_With_Dots_{6185CC21-BE89-448A-B3C0-D1C27112E595}
  1. Return an error because there are two projects with exactly the same project name.

@rainersigwald
Copy link
Member Author

I think it makes sense to support multiple colliding project names with their GUID suffix. I would do it for all three of the normalized project names in your example 1.

Doing so would require that CleanseProjectName know enough about the solution to be able to apply that transformation. I'm not sure how much it's worth building that knowledge in.

@joseotavioq
Copy link
Contributor

And what about the duplicated projects? In the example above, I showed two projects with the same non-normalized name (Project.Named.With.Dots) in the SLN file.

@rainersigwald
Copy link
Member Author

@joseotavioq I'm fine with leaving that as an error per #530. But if you wanted to use the disambiguation code needed for this to fix that too, I think it'd be helpful.

All of this is more helpful for folk who just build solutions--I don't imagine too many people will be typing -t:Project_Named_With_Dots_6185CC21-BE89-448A-B3C0-D1C27112E595 on the command line. But that's still helpful!

@joseotavioq
Copy link
Contributor

Hey @rainersigwald, I created a draft PR #5367. Could you please review the solution and see if it solves the problem?

@Nirmal4G
Copy link
Contributor

I use -t:Project_Name:Build pattern when I'm doing build on the command line. I have also used it on CI scripts.

But is there any possible way to change -t:Project_Named_With_Dots_6185CC21-BE89-448A-B3C0-D1C27112E595 into something more command line friendly -t:Project_Named_With_Dots_Alias2?

Project('{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}') = 'Project.Named.With.Dots.Alias1', 'Project.Named.With.Dots.csproj', '{FC2889D9-6050-4D2E-B022-979CCFEEAAAC}'
EndProject
Project('{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}') = 'Project_Named_With_Dots', 'Project_Named_With_Dots.csproj', '{ED30D4A3-1214-410B-82BB-B61E5A9D05CA}'
EndProject
Project('{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}') = 'Project.Named.With.Dots.Alias2', 'Project.Named.With.Dots.csproj', '{6185CC21-BE89-448A-B3C0-D1C27112E595}'
EndProject

Is this even possible with VS or MSBuild?

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 bug triaged
Projects
None yet
Development

No branches or pull requests

5 participants