cake-build / cake-build/cake

MSBuild SolutionParser interprets solution folders as project files

Open
#1,256 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.2k
Forks
778
Avg merge
1h 15m
Merged PRs (30d)
19

Description

### 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

``` csharp
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.(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
```

Contributor guide

Open the contributing guide

Research direction

Start at Cake.Common.Solution.Project.ProjectParser.Parse, referenced at ProjectParser.cs line 68, and trace how SolutionParserResult.Files is populated from the sample .sln entries. Reproduce the ParseSolution/ParseProject sequence, then ensure solution folders are not treated as ProjectFile objects or are represented distinctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.