cake-build / cake

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

DotNetCoreBuild fails with `Object reference not set to an instance of an object.` #985

Closed andycmaj closed 6 years ago

andycmaj commented 8 years ago

What You Are Seeing?

DotNetCoreBuild with default settings fails with Object reference not set to an instance of an object. when passing a directory glob as the project path (as indicated is possible in documentation).

What is Expected?

According to documentation, I expected this Task to build all directories in ./src/* (there's actually only one in my case).

It's possible this is a documentation bug and that this expectation should be corrected by updating the documentation example: DotNetCoreBuild("./src/*", settings);

What version of Cake are you using?

0.13.0

Are you running on a 32 or 64 bit system?

x64

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

OSX

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

Define task

Task("dnb")
    .Does(() =>
{
    DotNetCoreBuild("./src/*");
});

Run and observe error:

========================================
dnb
========================================
Executing task: dnb
Executing: /usr/local/share/dotnet/dotnet build ./src/*
Object reference not set to an instance of an object.
An error occured when executing task 'dnb'.
Error: Cake.Core.CakeException: .NET Core CLI: Process returned an error (exit code 1).
  at Cake.Core.Tooling.Tool`1[TSettings].Run (Cake.Core.Tooling.TSettings settings, Cake.Core.IO.ProcessArgumentBuilder arguments, Cake.Core.IO.ProcessSettings processSettings, System.Action`1 postAction) <0x37bc088 + 0x00267> in <filename unknown>:0
  at Cake.Core.Tooling.Tool`1[TSettings].Run (Cake.Core.Tooling.TSettings settings, Cake.Core.IO.ProcessArgumentBuilder arguments) <0x37bc048 + 0x0002f> in <filename unknown>:0
  at Cake.Common.Tools.DotNetCore.Build.DotNetCoreBuilder.Build (System.String project, Cake.Common.Tools.DotNetCore.Build.DotNetCoreBuildSettings settings) <0x37bbb10 + 0x0004b> in <filename unknown>:0
  at Cake.Common.Tools.DotNetCore.DotNetCoreAliases.DotNetCoreBuild (ICakeContext context, System.String project, Cake.Common.Tools.DotNetCore.Build.DotNetCoreBuildSettings settings) <0x37bb7c8 + 0x000d3> in <filename unknown>:0
  at Cake.Common.Tools.DotNetCore.DotNetCoreAliases.DotNetCoreBuild (ICakeContext context, System.String project) <0x37bb798 + 0x0001f> in <filename unknown>:0
  at CakeBuildScriptImpl.DotNetCoreBuild (System.String project) <0x37bb760 + 0x00023> in <filename unknown>:0
  at CakeBuildScriptImpl+<Execute>c__AnonStorey0.<>m__C () <0x37bb730 + 0x0001b> in <filename unknown>:0
  at Cake.Core.CakeTaskBuilderExtensions+<>c__DisplayClass4.<Does>b__3 (ICakeContext context) <0x37bb710 + 0x00014> in <filename unknown>:0
  at Cake.Core.ActionTask.Execute (ICakeContext context) <0x37bb658 + 0x00059> in <filename unknown>:0
  at Cake.Core.DefaultExecutionStrategy.Execute (Cake.Core.CakeTask task, ICakeContext context) <0x37bb490 + 0x00162> in <filename unknown>:0
  at Cake.Core.CakeEngine.ExecuteTask (ICakeContext context, IExecutionStrategy strategy, System.Diagnostics.Stopwatch stopWatch, Cake.Core.CakeTask task, Cake.Core.CakeReport report) <0x37bae98 + 0x00099> in <filename unknown>:0

Now remove glob in favor of actual dir path

Task("dnb")
    .Does(() =>
{
    DotNetCoreBuild("./src/ImsHealth.Automation");
});

Run and observe success

========================================
dnb
========================================
Executing task: dnb
Executing: /usr/local/share/dotnet/dotnet build ./src/ImsHealth.Automation
Project ImsHealth.Automation (.NETFramework,Version=v4.5.1) was previously compiled. Skipping compilation.
Finished executing task: dnb
devlead commented 8 years ago

@andycmaj sorry for not getting back to you earlier, is this still an issue with latest .NET tooling and Cake 16.2?

andycmaj commented 8 years ago

@devlead, yeah i think it is still an issue:

Successfully installed 'Cake 0.16.2' .NET Command Line Tools (1.0.0-preview3-003612)

$ ./build.sh -t dnb -v diagnostic
Module directory does not exist.
Analyzing build script...
Analyzing /Workspaces/appature/git/ImsHealth.Automation/build.cake...
Analyzing /Workspaces/appature/git/ImsHealth.Automation/src/ImsHealth.Automation/template/build.cake...
Processing build script...
Installing addins...
Package Cake.AWS.S3 has already been installed.
The addin Cake.AWS.S3 will reference AWSSDK.Core.dll.
The addin Cake.AWS.S3 will reference AWSSDK.S3.dll.
The addin Cake.AWS.S3 will reference Cake.AWS.S3.dll.
The addin Cake.AWS.S3 will reference MimeSharp.dll.
Creating script session...
Adding reference to Cake.Core.dll...
Adding reference to Cake.Common.dll...
Adding reference to Cake.exe...
Adding reference to System.Xml.dll...
Adding reference to System.Xml.Linq.dll...
Adding reference to System.Data.dll...
Adding reference to ImsHealth.Patterns.dll...
Adding reference to Newtonsoft.Json.dll...
Adding reference to ImsHealth.Automation.dll...
Adding reference to AWSSDK.Core.dll...
Adding reference to AWSSDK.S3.dll...
Adding reference to Cake.AWS.S3.dll...
Adding reference to MimeSharp.dll...
Importing namespace Amazon...
Importing namespace Amazon.S3...
Importing namespace Cake.AWS.S3...
Importing namespace Cake.Common...
Importing namespace Cake.Common.Build...
Importing namespace Cake.Common.Build.AppVeyor...
Importing namespace Cake.Common.Build.AppVeyor.Data...
Importing namespace Cake.Common.Build.BitbucketPipelines...
Importing namespace Cake.Common.Build.BitbucketPipelines.Data...
Importing namespace Cake.Common.Build.Bitrise...
Importing namespace Cake.Common.Build.Bitrise.Data...
Importing namespace Cake.Common.Build.ContinuaCI...
Importing namespace Cake.Common.Build.ContinuaCI.Data...
Importing namespace Cake.Common.Build.Jenkins...
Importing namespace Cake.Common.Build.Jenkins.Data...
Importing namespace Cake.Common.Build.TravisCI...
Importing namespace Cake.Common.Build.TravisCI.Data...
Importing namespace Cake.Common.Diagnostics...
Importing namespace Cake.Common.IO...
Importing namespace Cake.Common.IO.Paths...
Importing namespace Cake.Common.Net...
Importing namespace Cake.Common.Security...
Importing namespace Cake.Common.Solution...
Importing namespace Cake.Common.Solution.Project...
Importing namespace Cake.Common.Solution.Project.Properties...
Importing namespace Cake.Common.Solution.Project.XmlDoc...
Importing namespace Cake.Common.Text...
Importing namespace Cake.Common.Tools...
Importing namespace Cake.Common.Tools.Cake...
Importing namespace Cake.Common.Tools.Chocolatey...
Importing namespace Cake.Common.Tools.Chocolatey.ApiKey...
Importing namespace Cake.Common.Tools.Chocolatey.Config...
Importing namespace Cake.Common.Tools.Chocolatey.Features...
Importing namespace Cake.Common.Tools.Chocolatey.Install...
Importing namespace Cake.Common.Tools.Chocolatey.Pack...
Importing namespace Cake.Common.Tools.Chocolatey.Pin...
Importing namespace Cake.Common.Tools.Chocolatey.Push...
Importing namespace Cake.Common.Tools.Chocolatey.Sources...
Importing namespace Cake.Common.Tools.Chocolatey.Upgrade...
Importing namespace Cake.Common.Tools.DNU...
Importing namespace Cake.Common.Tools.DNU.Build...
Importing namespace Cake.Common.Tools.DNU.Pack...
Importing namespace Cake.Common.Tools.DNU.Restore...
Importing namespace Cake.Common.Tools.DotCover...
Importing namespace Cake.Common.Tools.DotCover.Analyse...
Importing namespace Cake.Common.Tools.DotCover.Cover...
Importing namespace Cake.Common.Tools.DotNetCore...
Importing namespace Cake.Common.Tools.DotNetCore.Build...
Importing namespace Cake.Common.Tools.DotNetCore.Execute...
Importing namespace Cake.Common.Tools.DotNetCore.Pack...
Importing namespace Cake.Common.Tools.DotNetCore.Publish...
Importing namespace Cake.Common.Tools.DotNetCore.Restore...
Importing namespace Cake.Common.Tools.DotNetCore.Run...
Importing namespace Cake.Common.Tools.DotNetCore.Test...
Importing namespace Cake.Common.Tools.DupFinder...
Importing namespace Cake.Common.Tools.Fixie...
Importing namespace Cake.Common.Tools.GitLink...
Importing namespace Cake.Common.Tools.GitReleaseManager...
Importing namespace Cake.Common.Tools.GitReleaseManager.AddAssets...
Importing namespace Cake.Common.Tools.GitReleaseManager.Close...
Importing namespace Cake.Common.Tools.GitReleaseManager.Create...
Importing namespace Cake.Common.Tools.GitReleaseManager.Export...
Importing namespace Cake.Common.Tools.GitReleaseManager.Publish...
Importing namespace Cake.Common.Tools.GitReleaseNotes...
Importing namespace Cake.Common.Tools.GitVersion...
Importing namespace Cake.Common.Tools.ILMerge...
Importing namespace Cake.Common.Tools.ILRepack...
Importing namespace Cake.Common.Tools.InspectCode...
Importing namespace Cake.Common.Tools.MSBuild...
Importing namespace Cake.Common.Tools.MSTest...
Importing namespace Cake.Common.Tools.NSIS...
Importing namespace Cake.Common.Tools.NuGet...
Importing namespace Cake.Common.Tools.NuGet.Install...
Importing namespace Cake.Common.Tools.NuGet.Pack...
Importing namespace Cake.Common.Tools.NuGet.Push...
Importing namespace Cake.Common.Tools.NuGet.Restore...
Importing namespace Cake.Common.Tools.NuGet.SetApiKey...
Importing namespace Cake.Common.Tools.NuGet.SetProxy...
Importing namespace Cake.Common.Tools.NuGet.Sources...
Importing namespace Cake.Common.Tools.NuGet.Update...
Importing namespace Cake.Common.Tools.NUnit...
Importing namespace Cake.Common.Tools.OctopusDeploy...
Importing namespace Cake.Common.Tools.OpenCover...
Importing namespace Cake.Common.Tools.ReportGenerator...
Importing namespace Cake.Common.Tools.ReportUnit...
Importing namespace Cake.Common.Tools.Roundhouse...
Importing namespace Cake.Common.Tools.SignTool...
Importing namespace Cake.Common.Tools.SpecFlow...
Importing namespace Cake.Common.Tools.SpecFlow.StepDefinitionReport...
Importing namespace Cake.Common.Tools.SpecFlow.TestExecutionReport...
Importing namespace Cake.Common.Tools.TextTransform...
Importing namespace Cake.Common.Tools.VSTest...
Importing namespace Cake.Common.Tools.WiX...
Importing namespace Cake.Common.Tools.WiX.Heat...
Importing namespace Cake.Common.Tools.XBuild...
Importing namespace Cake.Common.Tools.XUnit...
Importing namespace Cake.Common.Xml...
Importing namespace Cake.Core...
Importing namespace Cake.Core.Diagnostics...
Importing namespace Cake.Core.IO...
Importing namespace Cake.Core.Scripting...
Importing namespace Cake.Core.Tooling...
Importing namespace ImsHealth.Automation.Deploy...
Importing namespace ImsHealth.Automation.Docker...
Importing namespace ImsHealth.Automation.Ecs...
Importing namespace ImsHealth.Automation.Env...
Importing namespace ImsHealth.Automation.Git...
Importing namespace ImsHealth.Automation.Layer0...
Importing namespace ImsHealth.Automation.Ssh...
Importing namespace ImsHealth.Automation.Wyam...
Importing namespace ImsHealth.Patterns.Commands...
Importing namespace System...
Importing namespace System.Collections.Generic...
Importing namespace System.IO...
Importing namespace System.Linq...
Importing namespace System.Text...
Importing namespace System.Threading.Tasks...
Compiling build script...
Prerelease Build Number: t161026213018

========================================
dnb
========================================
Executing task: dnb
Executing: /usr/local/share/dotnet/dotnet build "./src/*"
Object reference not set to an instance of an object.
An error occured when executing task 'dnb'.
Error: Cake.Core.CakeException: .NET Core CLI: Process returned an error (exit code 1).
  at Cake.Core.Tooling.Tool`1[TSettings].ProcessExitCode (System.Int32 exitCode) [0x00036] in <92cfa6bf99f847e28f9ae79884fd42f0>:0
  at Cake.Core.Tooling.Tool`1[TSettings].Run (TSettings settings, Cake.Core.IO.ProcessArgumentBuilder arguments, Cake.Core.IO.ProcessSettings processSettings, System.Action`1[T] postAction) [0x000c9] in <92cfa6bf99f847e28f9ae79884fd42f0>:0
  at Cake.Core.Tooling.Tool`1[TSettings].Run (TSettings settings, Cake.Core.IO.ProcessArgumentBuilder arguments) [0x00001] in <92cfa6bf99f847e28f9ae79884fd42f0>:0
  at Cake.Common.Tools.DotNetCore.Build.DotNetCoreBuilder.Build (System.String project, Cake.Common.Tools.DotNetCore.Build.DotNetCoreBuildSettings settings) [0x00033] in <af6ceae32b564cc0b20522cb0b6a7e6f>:0
  at Cake.Common.Tools.DotNetCore.DotNetCoreAliases.DotNetCoreBuild (Cake.Core.ICakeContext context, System.String project, Cake.Common.Tools.DotNetCore.Build.DotNetCoreBuildSettings settings) [0x00044] in <af6ceae32b564cc0b20522cb0b6a7e6f>:0
  at Cake.Common.Tools.DotNetCore.DotNetCoreAliases.DotNetCoreBuild (Cake.Core.ICakeContext context, System.String project) [0x00001] in <af6ceae32b564cc0b20522cb0b6a7e6f>:0
  at CakeBuildScriptImpl.DotNetCoreBuild (System.String project) [0x00006] in <16066924bc2c4aeeb17ea8d630028915>:0
  at CakeBuildScriptImpl+<Execute>c__AnonStorey0.<>m__C () [0x00000] in <16066924bc2c4aeeb17ea8d630028915>:0
  at Cake.Core.CakeTaskBuilderExtensions+<>c__DisplayClass4_0.<Does>b__0 (Cake.Core.ICakeContext context) [0x00000] in <92cfa6bf99f847e28f9ae79884fd42f0>:0
  at Cake.Core.ActionTask.Execute (Cake.Core.ICakeContext context) [0x00019] in <92cfa6bf99f847e28f9ae79884fd42f0>:0
  at Cake.Core.DefaultExecutionStrategy.Execute (Cake.Core.CakeTask task, Cake.Core.ICakeContext context) [0x0008a] in <92cfa6bf99f847e28f9ae79884fd42f0>:0
  at Cake.Core.CakeEngine.ExecuteTask (Cake.Core.ICakeContext context, Cake.Core.IExecutionStrategy strategy, System.Diagnostics.Stopwatch stopWatch, Cake.Core.CakeTask task, Cake.Core.CakeReport report) [0x0001e] in <92cfa6bf99f847e28f9ae79884fd42f0>:0
petertiedemann commented 8 years ago

I am also seeing this issue with:

Cake 0.16.2+Branch.main.Sha.fb23be463dacfa51c9b19a7cd111149dda7e8c6b .NET Command Line Tools (1.0.0-preview2-003133)

As described above, directly specifying the paths fixes the problem.

andycmaj commented 6 years ago

i don't have this problem anymore, since you can now build sln files directly. closing this