Open kimbell opened 6 years ago
Looks like a bug in dotnet. We experience similar behavior:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.String.get_Chars(Int32 index)
at Microsoft.DotNet.Cli.CommandLine.StringExtensions.HasPrefix(String arg)
at Microsoft.DotNet.Cli.CommandLine.StringExtensions.<Lex>d__7.MoveNext()
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source, Int32& length)
at System.Collections.Generic.Queue`1..ctor(IEnumerable`1 collection)
at Microsoft.DotNet.Cli.CommandLine.Parser.Parse(IReadOnlyCollection`1 rawArgs, Boolean isProgressive)
at Microsoft.DotNet.Cli.CommandLine.Parser.Parse(String[] args)
at Microsoft.DotNet.Cli.ParserExtensions.ParseFrom(Parser parser, String context, String[] args)
at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
at Microsoft.DotNet.Cli.Program.Main(String[] args)
I am getting the same:
Time Elapsed 00:00:02.24
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.String.get_Chars(Int32 index)
at Microsoft.DotNet.Cli.CommandLine.StringExtensions.HasPrefix(String arg)
at Microsoft.DotNet.Cli.CommandLine.StringExtensions.<Lex>d__7.MoveNext()
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source, Int32& length)
at System.Collections.Generic.Queue`1..ctor(IEnumerable`1 collection)
at Microsoft.DotNet.Cli.CommandLine.Parser.Parse(IReadOnlyCollection`1 rawArgs, Boolean isProgressive)
at Microsoft.DotNet.Cli.CommandLine.Parser.Parse(String[] args)
at Microsoft.DotNet.Cli.ParserExtensions.ParseFrom(Parser parser, String context, String[] args)
at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
at Microsoft.DotNet.Cli.Program.Main(String[] args)
when running:
dotnet build $scriptsDir --configuration RELEASE --verbosity normal --version-suffix '' /property:VersionPrefix=0.0.0
I have this version.props which I am referencing from all projects:
<!-- This file may be overwritten by automation. Only values allowed here are VersionPrefix and VersionSuffix. -->
<Project>
<PropertyGroup>
<VersionPrefix>0.0.0</VersionPrefix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
</Project>
Let me know if you need anything else from me to repro this. I will try to get a clean repro project as well.
This worked as expected:
dotnet build $scriptsDir --configuration RELEASE --verbosity normal /property:VersionPrefix=0.0.0 /property:VersionSuffix=''
@kimbell Have you tried pointing dotnet build
at the solution file? That's what I generally do.
I'm running Cake 0.23.0 locally on Windows 10 Pro 64 bit version.
In my Cake script I've been using "" for the project in order to let the CLI tools figure out things. I basically want to build everything.
This worked fine with the 1.1 tooling, but fails with the 2.0 tooling.
Turning on diagnostics information, I see that following command is being called
"C:/Program Files/dotnet/dotnet.exe" build "" --configuration Release /property:AssemblyVersion=1.0.2.1 /property:FileVersion=1.0.2.1 /property:PackageVersion=1.0.2.1
Note the "" after build. If I remove them, things work fine. If I try to pass inn null in the Cake script, I get an ArgumentNullException.
I had a look at the code and think I've spotted the problem in https://github.com/cake-build/cake/blob/develop/src/Cake.Common/Tools/DotNetCore/Build/DotNetCoreBuilder.cs
The Build() method has a null check for project, but when you look at the GetArguments() method, you can see that also has a null check for project. If it's not defined, you don't escape an empty string.
From what I can tell, it should only be a matter of removing the null check from the Build() method.