cake-build / cake

:cake: Cake (C# Make) is a cross platform build automation system.
https://cakebuild.net
MIT License
3.89k stars 725 forks source link

MSBuild SolutionParser interprets solution folders as project files #1256

Open cpx86 opened 8 years ago

cpx86 commented 8 years ago

What You Are Seeing?

When parsing a solution, solution folders are added to SolutionParserResult.Files as ProjectFile objects with the FilePath set to the name of the solution folder name.

What is Expected?

The solution folders would be either ignored, or represented as a different type than ProjectFile.

What version of Cake are you using?

0.15.2+Branch.main.Sha.c2ca4f7ca51c59dc9c47c9830125b4e66cf14e7a

How Did You Get This To Happen? (Steps to Reproduce)

Sample cake snippet

var parsedSolution = ParseSolution("SampleSolution.sln");
var parsedProjects = parsedSolution.Projects.Select(p => ParseProject(p.Path)).ToList();

Sample solution snippet

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleProject", "src\SampleProject\SampleProject.csproj", "{DE89E10E-1793-4D8C-81C8-12982607B2D9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0C3E1B23-CF55-49C7-8C1D-38FA8DFC7F06}"
EndProject

Output Log

Compiling build script...
Error: Cake.Core.CakeException: Project file 'C:/code/cake-test/src' do not exist.
   at Cake.Common.Solution.Project.ProjectParser.Parse(FilePath projectPath) in C:\code\github\cake\src\Cake.Common\Solution\Project\ProjectParser.cs:line 68
   at Cake.Common.Solution.Project.ProjectAliases.ParseProject(ICakeContext context, FilePath projectPath) in C:\code\github\cake\src\Cake.Common\Solution\Project\ProjectAliases.cs:line 66
   at Submission#0.ParseProject(FilePath projectPath)
   at Submission#0.<.ctor>b__0(SolutionProject p)
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Submission#0..ctor(Session session, Object& submissionResult)
   at Submission#0.<Factory>(Session session)
   at Roslyn.Scripting.CommonScriptEngine.Execute[T](String code, String path, DiagnosticBag diagnostics, Session session, Boolean isInteractive)
   at Roslyn.Scripting.Session.Execute(String code)
   at Cake.Scripting.Roslyn.Stable.DefaultRoslynScriptSession.Execute(Script script) in C:\code\github\cake\src\Cake\Scripting\Roslyn\Stable\DefaultRoslynScriptSession.cs:line 33
   at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments) in C:\code\github\cake\src\Cake.Core\Scripting\ScriptRunner.cs:line 201
   at Cake.Commands.BuildCommand.Execute(CakeOptions options) in C:\code\github\cake\src\Cake\Commands\BuildCommand.cs:line 34
   at Cake.CakeApplication.Run(CakeOptions options) in C:\code\github\cake\src\Cake\CakeApplication.cs:line 46
   at Cake.Program.Main() in C:\code\github\cake\src\Cake\Program.cs:line 75
wwwlicious commented 7 years ago

Came across the same issue and created an extension to filter out SolutionFolders. Details here if it helps