Skip to content

Conversation

@pjcollins
Copy link
Member

Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3520928&view=ms.vss-test-web.build-test-results-tab&runId=11613622&resultId=100500&paneView=debug

Xamarin.Android.Build.Task tests which attempt to look up the path to
aapt/aapt2 recently started failing on the Azure Pipelines hosted macOS
machine pool [0]. I suspect this is caused by a preview version of tools
ending up on the machine. I think we can be a bit more lenient when
locating the latest version of build-tools by instead using a string
comparison. This will also allow the relevant tests to use a preview
version of build-tools if they exist. Additional logging has also been
added to confirm this hypothesis.

[0]:

System.FormatException : Input string was not in a correct format.
    at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey) [0x0001a] in <8855e4c75b1445438dde4104dd4134bb>:0
    at System.Number.ParseInt32 (System.ReadOnlySpan`1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info) [0x00016] in <8855e4c75b1445438dde4104dd4134bb>:0
    at System.Int32.Parse (System.ReadOnlySpan`1[T] s, System.Globalization.NumberStyles style, System.IFormatProvider provider) [0x0000e] in <8855e4c75b1445438dde4104dd4134bb>:0
    at System.Version.TryParseComponent (System.ReadOnlySpan`1[T] component, System.String componentName, System.Boolean throwOnFailure, System.Int32& parsedComponent) [0x0000b] in <8855e4c75b1445438dde4104dd4134bb>:0
    at System.Version.ParseVersion (System.ReadOnlySpan`1[T] input, System.Boolean throwOnFailure) [0x0011a] in <8855e4c75b1445438dde4104dd4134bb>:0
    at System.Version.Parse (System.String input) [0x00014] in <8855e4c75b1445438dde4104dd4134bb>:0
    at System.Version..ctor (System.String version) [0x00014] in <8855e4c75b1445438dde4104dd4134bb>:0
    at Xamarin.Android.Build.Tests.BaseTest+<>c.<GetPathToLatestBuildTools>b__48_0 (System.String x) [0x00006] in <e6ad3936767d47cea783c180acfe7cf6>:0
    at System.Linq.EnumerableSorter`2[TElement,TKey].ComputeKeys (TElement[] elements, System.Int32 count) [0x00010] in <89222f8e94f04b5cb12f2328985a10a8>:0
    at System.Linq.EnumerableSorter`1[TElement].ComputeMap (TElement[] elements, System.Int32 count) [0x00000] in <89222f8e94f04b5cb12f2328985a10a8>:0
    at System.Linq.EnumerableSorter`1[TElement].Sort (TElement[] elements, System.Int32 count) [0x00000] in <89222f8e94f04b5cb12f2328985a10a8>:0
    at System.Linq.OrderedEnumerable`1[TElement].SortedMap (System.Linq.Buffer`1[TElement] buffer) [0x00006] in <89222f8e94f04b5cb12f2328985a10a8>:0
    at System.Linq.OrderedEnumerable`1+<GetEnumerator>d__3[TElement].MoveNext () [0x0003d] in <89222f8e94f04b5cb12f2328985a10a8>:0
    at Xamarin.Android.Build.Tests.BaseTest.GetPathToLatestBuildTools (System.String exe) [0x00061] in <e6ad3936767d47cea783c180acfe7cf6>:0
    at Xamarin.Android.Build.Tests.BaseTest.GetPathToAapt () [0x00015] in <e6ad3936767d47cea783c180acfe7cf6>:0
    at Xamarin.Android.Build.Tests.ManagedResourceParserTests.CompareAaptAndManagedParserOutputWithCustomIds () [0x000d2] in <e6ad3936767d47cea783c180acfe7cf6>:0

Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3520928&view=ms.vss-test-web.build-test-results-tab&runId=11613622&resultId=100500&paneView=debug

Xamarin.Android.Build.Task tests which attempt to look up the path to
aapt/aapt2 recently started failing on the Azure Pipelines hosted macOS
machine pool [0]. I suspect this is caused by a preview version of tools
ending up on the machine. I think we can be a bit more lenient when
locating the latest version of build-tools by instead using a string
comparison. This will also allow the relevant tests to use a preview
version of build-tools if they exist. Additional logging has also been
added to confirm this hypothesis.

[0]:

    System.FormatException : Input string was not in a correct format.
        at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey) [0x0001a] in <8855e4c75b1445438dde4104dd4134bb>:0
        at System.Number.ParseInt32 (System.ReadOnlySpan`1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info) [0x00016] in <8855e4c75b1445438dde4104dd4134bb>:0
        at System.Int32.Parse (System.ReadOnlySpan`1[T] s, System.Globalization.NumberStyles style, System.IFormatProvider provider) [0x0000e] in <8855e4c75b1445438dde4104dd4134bb>:0
        at System.Version.TryParseComponent (System.ReadOnlySpan`1[T] component, System.String componentName, System.Boolean throwOnFailure, System.Int32& parsedComponent) [0x0000b] in <8855e4c75b1445438dde4104dd4134bb>:0
        at System.Version.ParseVersion (System.ReadOnlySpan`1[T] input, System.Boolean throwOnFailure) [0x0011a] in <8855e4c75b1445438dde4104dd4134bb>:0
        at System.Version.Parse (System.String input) [0x00014] in <8855e4c75b1445438dde4104dd4134bb>:0
        at System.Version..ctor (System.String version) [0x00014] in <8855e4c75b1445438dde4104dd4134bb>:0
        at Xamarin.Android.Build.Tests.BaseTest+<>c.<GetPathToLatestBuildTools>b__48_0 (System.String x) [0x00006] in <e6ad3936767d47cea783c180acfe7cf6>:0
        at System.Linq.EnumerableSorter`2[TElement,TKey].ComputeKeys (TElement[] elements, System.Int32 count) [0x00010] in <89222f8e94f04b5cb12f2328985a10a8>:0
        at System.Linq.EnumerableSorter`1[TElement].ComputeMap (TElement[] elements, System.Int32 count) [0x00000] in <89222f8e94f04b5cb12f2328985a10a8>:0
        at System.Linq.EnumerableSorter`1[TElement].Sort (TElement[] elements, System.Int32 count) [0x00000] in <89222f8e94f04b5cb12f2328985a10a8>:0
        at System.Linq.OrderedEnumerable`1[TElement].SortedMap (System.Linq.Buffer`1[TElement] buffer) [0x00006] in <89222f8e94f04b5cb12f2328985a10a8>:0
        at System.Linq.OrderedEnumerable`1+<GetEnumerator>d__3[TElement].MoveNext () [0x0003d] in <89222f8e94f04b5cb12f2328985a10a8>:0
        at Xamarin.Android.Build.Tests.BaseTest.GetPathToLatestBuildTools (System.String exe) [0x00061] in <e6ad3936767d47cea783c180acfe7cf6>:0
        at Xamarin.Android.Build.Tests.BaseTest.GetPathToAapt () [0x00015] in <e6ad3936767d47cea783c180acfe7cf6>:0
        at Xamarin.Android.Build.Tests.ManagedResourceParserTests.CompareAaptAndManagedParserOutputWithCustomIds () [0x000d2] in <e6ad3936767d47cea783c180acfe7cf6>:0
{
var path = Path.Combine (AndroidSdkPath, "build-tools");
foreach (var dir in Directory.GetDirectories (path, "*", SearchOption.TopDirectoryOnly).OrderByDescending (x => new Version (Path.GetFileName (x)))) {
foreach (var dir in Directory.GetDirectories (path, "*", SearchOption.TopDirectoryOnly).OrderByDescending (x => Path.GetFileName (x))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pity this will fails when sorting { "2", "10" }, because it sorts "stringly", not numerically.

Fortunately this is unlikely to be a problem now, because we're likely to always have two digit numbers. (But when we start hitting Build-tools 100, watch out!)

Unfortunately, this also sorts { "29.0.0-rc2", "29.0.0-rc1", "29.0.0" } in that order, such that the -rc2 will be preferred first, over the "stable" 29.0.0 version.

var path = Path.Combine (AndroidSdkPath, "build-tools");
foreach (var dir in Directory.GetDirectories (path, "*", SearchOption.TopDirectoryOnly).OrderByDescending (x => new Version (Path.GetFileName (x)))) {
foreach (var dir in Directory.GetDirectories (path, "*", SearchOption.TopDirectoryOnly).OrderByDescending (x => Path.GetFileName (x))) {
TestContext.Out.WriteLine ($"Found build tools version: {dir}.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonpryor jonpryor merged commit 7aaea22 into dotnet:master Mar 4, 2020
jonpryor pushed a commit that referenced this pull request Mar 4, 2020
Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3520928&view=ms.vss-test-web.build-test-results-tab&runId=11613622&resultId=100500&paneView=debug

The **Xamarin.Android.Build.Tests - macOS** job has started reporting
some failures within the past couple of days:

	System.FormatException : Input string was not in a correct format.
	    at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey)
	    at System.Number.ParseInt32 (System.ReadOnlySpan`1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info)
	    at System.Int32.Parse (System.ReadOnlySpan`1[T] s, System.Globalization.NumberStyles style, System.IFormatProvider provider)
	    at System.Version.TryParseComponent (System.ReadOnlySpan`1[T] component, System.String componentName, System.Boolean throwOnFailure, System.Int32& parsedComponent)
	    at System.Version.ParseVersion (System.ReadOnlySpan`1[T] input, System.Boolean throwOnFailure)
	    at System.Version.Parse (System.String input)
	    at System.Version..ctor (System.String version)
	    at Xamarin.Android.Build.Tests.BaseTest+<>c.<GetPathToLatestBuildTools>b__48_0 (System.String x)
	    at System.Linq.EnumerableSorter`2[TElement,TKey].ComputeKeys (TElement[] elements, System.Int32 count)
	    at System.Linq.EnumerableSorter`1[TElement].ComputeMap (TElement[] elements, System.Int32 count)
	    at System.Linq.EnumerableSorter`1[TElement].Sort (TElement[] elements, System.Int32 count)
	    at System.Linq.OrderedEnumerable`1[TElement].SortedMap (System.Linq.Buffer`1[TElement] buffer)
	    at System.Linq.OrderedEnumerable`1+<GetEnumerator>d__3[TElement].MoveNext ()
	    at Xamarin.Android.Build.Tests.BaseTest.GetPathToLatestBuildTools (System.String exe)
	    at Xamarin.Android.Build.Tests.BaseTest.GetPathToAapt ()
	    at Xamarin.Android.Build.Tests.ManagedResourceParserTests.CompareAaptAndManagedParserOutputWithCustomIds ()

What's happened is that somehow, for some reason,
Build-tools 30.0.0-rc1 has been installed onto the build machine:

	$HOME/Library/Android/sdk/build-tools/30.0.0-rc1

`30.0.0-rc` cannot be parsed by `System.Version`.

I think we can be a bit more lenient when locating the latest version
of build-tools by instead using a string comparison.  This will also
allow the relevant tests to use a preview version of build-tools if
they exist.

Additional logging has also been added to confirm this hypothesis,
which is how we determined that it's Build-tools 30.0.0-rc1.
@pjcollins pjcollins deleted the build-tools-formatex branch March 4, 2020 05:14
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants