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

ParseSolution throws IndexOutOfRangeException on empty lines #3143

Closed
nmbro opened this issue Feb 15, 2021 · 3 comments · Fixed by #3147
Closed

ParseSolution throws IndexOutOfRangeException on empty lines #3143

nmbro opened this issue Feb 15, 2021 · 3 comments · Fixed by #3147
Assignees
Labels
Milestone

Comments

@nmbro
Copy link
Contributor

nmbro commented Feb 15, 2021

What You Are Seeing?

ParseSolution(ICakeContext context, FilePath solutionPath) doesn't handle empty lines in the solution file correctly.

What is Expected?

It's expected for it to just ignore the empty lines.

What version of Cake are you using?

1.0.0

Are you running on a 32 or 64 bit system?

64 bit, shouldn't matter

What environment are you running on? Windows? Linux? Mac?

Windows

Are you running on a CI Server? If so, which one?

no

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

Clone https://github.com/nmbro/cake-bug2
Run the build.ps1

The steps to reproduce is that the solution file has to have a blank line in the NestedProject section:

	GlobalSection(NestedProjects) = preSolution

		{59882916-5E07-4B05-91B2-C4449B095B78} = {2A10A5BE-0BDF-47BA-ADC2-33C669B1FDC2}
		{ED234CCE-59CC-442B-A059-C5742A191803} = {D7FA2608-3CBB-4C1B-A648-FEA180C64690}
	EndGlobalSection

This causes the Cake.Common.Solution.SolutionAliases.ParseSolution(ICakeContext context, FilePath solutionPath) to fail.

Output Log

PS C:\dev\cake-bug2> .\build.ps1 -w C:\dev\cake-bug2\ -v Diagnostic
NuGet Config not specified. Will use NuGet default mechanism for resolving it.
Registering task: SolutionBug
Registering task: Default

========================================
SolutionBug
========================================
Executing task: SolutionBug
An error occurred when executing task 'SolutionBug'.
Error: System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Cake.Common.Solution.SolutionParser.<>c__DisplayClass5_0.<ParseNestedProjectLine>b__0(SolutionProject x)
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at Cake.Common.Solution.SolutionParser.ParseNestedProjectLine(List`1 projects, String line)
   at Cake.Common.Solution.SolutionParser.Parse(FilePath solutionPath)
   at Cake.Common.Solution.SolutionAliases.ParseSolution(ICakeContext context, FilePath solutionPath)
   at SolutionTask.Run(BuildContext context) in C:\dev\cake-bug2\build\Program.cs:line 28
   at Cake.Frosting.FrostingTask`1.Cake.Frosting.IFrostingTask.RunAsync(ICakeContext context)
   at Cake.Core.CakeTask.Execute(ICakeContext context)
   at Cake.Core.DefaultExecutionStrategy.ExecuteAsync(CakeTask task, ICakeContext context)
   at Cake.Core.CakeEngine.ExecuteTaskAsync(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report)
   at Cake.Core.CakeEngine.ExecuteTaskAsync(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report)
   at Cake.Core.CakeEngine.ExecuteTaskAsync(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report)
   at Cake.Core.CakeEngine.RunTask(ICakeContext context, IExecutionStrategy strategy, CakeTask task, String target, Stopwatch stopWatch, CakeReport report)
   at Cake.Core.CakeEngine.RunTargetAsync(ICakeContext context, IExecutionStrategy strategy, ExecutionSettings settings)
   at Cake.Cli.BuildScriptHost`1.RunTargetAsync(String target)
   at Cake.Core.Scripting.ScriptHost.RunTarget(String target)
   at Cake.Frosting.Internal.FrostingEngine`1.Run(String target)
   at Cake.Frosting.Internal.DefaultCommand.Execute(CommandContext context, DefaultCommandSettings settings)
@gep13
Copy link
Member

gep13 commented Feb 15, 2021

@nmbro i am curious.... Does this happen with the same method in Cake.Incubator?

It has been a long term goal to bring the methods from Cake.Incubator into Cake properly.

@nmbro
Copy link
Contributor Author

nmbro commented Feb 15, 2021

I can give it a shot; actually I can't seem to find a ParseSolution function in Cake.Incubator?

nmbro added a commit to nmbro/cake that referenced this issue Feb 15, 2021
(cake-buildGH-3143) Don't try to parse empty solution file lines
nmbro added a commit to nmbro/cake that referenced this issue Feb 16, 2021
(cake-buildGH-3143) Don't try to parse empty solution file lines
nmbro added a commit to nmbro/cake that referenced this issue Feb 16, 2021
augustoproiete pushed a commit to nmbro/cake that referenced this issue Feb 17, 2021
augustoproiete added a commit that referenced this issue Feb 17, 2021
GH-3143: Don't try to parse empty solution file lines
@cake-build-bot
Copy link

🎉 This issue has been resolved in version v1.1.0 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants