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

CleanDirectories Throws NullReferenceException When Token Is Null #1831

Closed
jpreese opened this issue Sep 25, 2017 · 1 comment
Closed

CleanDirectories Throws NullReferenceException When Token Is Null #1831

jpreese opened this issue Sep 25, 2017 · 1 comment
Labels
Milestone

Comments

@jpreese
Copy link
Contributor

jpreese commented Sep 25, 2017

What You Are Seeing?

When calling CleanDirectories() with an invalid Glob pattern (in this case a trailing slash), a NullReferenceException is thrown.

What is Expected?

The method should behave the same as unable to locate the directory.

What version of Cake are you using?

0.22.2

Are you running on a 32 or 64 bit system?

64 bit

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)

Run the following cake script

var target = Argument("target", "Default");

Task("Default")
  .Does(() =>
  {
    CleanDirectories("somedir/");
  });

RunTarget(target);

Output Log

An error occurred when executing task 'Default'.
Error: System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Cake.Core.IO.Globbing.GlobParser.ParseSegment(GlobParserContext context)
   at Cake.Core.IO.Globbing.GlobParser.Parse(GlobParserContext context)
   at Cake.Core.IO.Globber.Match(String pattern, Func`2 predicate)
   at Cake.Common.IO.GlobbingAliases.GetDirectories(ICakeContext context, String pattern)
   at Cake.Common.IO.DirectoryAliases.CleanDirectories(ICakeContext context, String pattern)
   at Submission#0.CleanDirectories(String pattern)
   at Submission#0.<<Initialize>>b__0_0()
   at Cake.Core.ActionTask.Execute(ICakeContext context)
   at Cake.Core.DefaultExecutionStrategy.Execute(CakeTask task, ICakeContext context)
   at Cake.Core.CakeEngine.ExecuteTask(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report)
   at Cake.Core.CakeEngine.RunTarget(ICakeContext context, IExecutionStrategy strategy, String target)
   at Cake.Scripting.BuildScriptHost.RunTarget(String target)
   at Submission#0.<<Initialize>>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.<RunSubmissionsAsync>d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Scripting.Script`1.<RunSubmissionsAsync>d__21.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Cake.Scripting.Roslyn.RoslynScriptSession.Execute(Script script)
   at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments)
   at Cake.Commands.BuildCommand.Execute(CakeOptions options)
   at Cake.CakeApplication.Run(CakeOptions options)
   at Cake.Program.Main()
---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.
   at Cake.Core.IO.Globbing.GlobParser.ParseSegment(GlobParserContext context)
   at Cake.Core.IO.Globbing.GlobParser.Parse(GlobParserContext context)
   at Cake.Core.IO.Globber.Match(String pattern, Func`2 predicate)
   at Cake.Common.IO.GlobbingAliases.GetDirectories(ICakeContext context, String pattern)
   at Cake.Common.IO.DirectoryAliases.CleanDirectories(ICakeContext context, String pattern)
   at Submission#0.CleanDirectories(String pattern)
   at Submission#0.<<Initialize>>b__0_0()
   at Cake.Core.ActionTask.Execute(ICakeContext context)
   at Cake.Core.DefaultExecutionStrategy.Execute(CakeTask task, ICakeContext context)
   at Cake.Core.CakeEngine.ExecuteTask(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report)
   at Cake.Core.CakeEngine.RunTarget(ICakeContext context, IExecutionStrategy strategy, String target)
   at Cake.Scripting.BuildScriptHost.RunTarget(String target)
   at Submission#0.<<Initialize>>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.<RunSubmissionsAsync>d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Scripting.Script`1.<RunSubmissionsAsync>d__21.MoveNext()<---
@devlead
Copy link
Member

devlead commented Sep 26, 2017

Fixed by #1832

@devlead devlead closed this as completed Sep 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants