Skip to content

Number unexpectedly not recognized when in Swedish locale #5502

@danmoseley

Description

@danmoseley

Steps to reproduce

Build this with English (US) Windows settings. It will succeed.
Now go to Control Panel>Region>Change Date/Time/number formats>Formats tab, change to Swedish, OK. No need to reboot or reopen the command prompt.
Now build it again.

<Project>

  <PropertyGroup>
    <p>abc</p>
  </PropertyGroup>

  <Target Name="t" Condition=" $(p.IndexOf('x')) >= 0 " />
  
</Project>

Expected behavior

Success- no output - the condition is valid and evaluates to -1 >= 0

Actual behavior

C:\proj\x.proj(7,34): error MSB4086: A numeric comparison was attempted on "$(p.IndexOf('x'))" that evaluates to "-1" instead of a number, in condition " $(p.IndexOf('x')) >= 0 ".

Environment data

msbuild /version output:

C:\proj>dotnet msbuild /version
Microsoft (R) Build Engine version 16.7.0-preview-20310-07+ee1c9fd0c for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

16.7.0.31007

OS info:

Windows 10, 2004

Comments

We should parse all numbers out of strings in Invariant mode:

https://github.com/microsoft/msbuild/blob/e70a3159d64f9ed6ec3b60253ef863fa883a99b1/src/Build/Evaluation/Conditionals/NumericComparisonExpressionNode.cs#L44
https://github.com/microsoft/msbuild/blob/e70a3159d64f9ed6ec3b60253ef863fa883a99b1/src/Shared/ConversionUtilities.cs#L99

I'm not sure what's going on. Note also, that the negative sign in Sweden is apparently the regular -.

cc @maloo

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions