Skip to content

NativeAOT publish fails on fi_FI.utf8 locale #98550

Closed

Description

@De-Crypted

Describe the bug

Trying to publish freshly created console application with dotnet publish /p:PublishAot=true produces error:

MSBuild version 17.9.4+90725d08d for .NET
/home/user/.nuget/packages/microsoft.dotnet.ilcompiler/8.0.2/build/Microsoft.DotNet.ILCompiler.SingleEntry.targets(9,16): error MSB4086: A numeric comparison was attempted on "$(_indexOfPeriod)" that evaluates to "−1" instead of a number, in condition "'$(_indexOfPeriod)' > -1". [/home/user/sources/project/daemon/daemon.csproj]

Note that the first -1 actually has "U+2212 : MINUS SIGN" printed in the console.

As a workaround locale can be set to en_US.utf8 and the publish works as expected.

To Reproduce

On Linux machine set locale to fi_FI.utf8
Create console application with

dotnet new console -n app

Publish it with

dotnet publish /p:PublishAot=true

Further technical details

.NET SDK:
 Version:           8.0.200
 Commit:            438cab6a9d
 Workload version:  8.0.200-manifests.cdf2cc8e

Runtime Environment:
 OS Name:     manjaro
 OS Version:  
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /home/tk/.dotnet/sdk/8.0.200/

.NET workloads installed:
There are no installed workloads to display.

Host:
  Version:      8.0.2
  Architecture: x64
  Commit:       1381d5ebd2

.NET SDKs installed:
  8.0.200 [/home/tk/.dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.2 [/home/tk/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.2 [/home/tk/.dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_ROOT       [/usr/share/dotnet]

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Activity

  1. ghost added
    untriaged
    on Feb 15, 2024
  2. transferred this issue fromdotnet/sdkon Feb 16, 2024
  3. ghost added
    needs-area-label
    on Feb 16, 2024
  4. added and removed
    needs-area-label
    untriaged
    on Feb 16, 2024
  5. added this to the 9.0.0 milestone on Feb 16, 2024
  6. akoeplinger commented on Feb 16, 2024

    @akoeplinger
    Member

    It looks like <_indexOfPeriod>$(_originalTargetOS.IndexOf('.'))</_indexOfPeriod> causes the int->string conversion to happen with current culture:

    <_indexOfPeriod>$(_originalTargetOS.IndexOf('.'))</_indexOfPeriod>
    <_originalTargetOS Condition="'$(_indexOfPeriod)' &gt; -1">$(_originalTargetOS.SubString(0, $(_indexOfPeriod)))</_originalTargetOS>

  7. akoeplinger commented on Feb 16, 2024

    @akoeplinger
    Member

    We can't use .ToString(CultureInfo.InvariantCulture) since CultureInfo is not allowed in msbuild.

    A workaround I found is using .ToString('0;-0') to use an explicit minus sign for negative numbers in the format string.
    Or we could just duplicate the .IndexOf() call instead of using the msbuild property as an intermediate.

    Any preferences?

  8. tmds commented on Feb 16, 2024

    @tmds
    Member

    .NET SDKs installed:
    8.0.200 [/home/tk/.dotnet/sdk]

    I wonder if you're seeing this because of dotnet/msbuild#9449.

    If you export MSBUILDDISABLEFEATURESFROMVERSION=17.10, does it work?

  9. akoeplinger commented on Feb 16, 2024

    @akoeplinger
    Member

    @tmds I don't think so, that PR only changes the culture of the Exec task which is not used here.

  10. MichalStrehovsky commented on Feb 16, 2024

    @MichalStrehovsky
    Member

    We can't use .ToString(CultureInfo.InvariantCulture) since CultureInfo is not allowed in msbuild.

    A workaround I found is using .ToString('0;-0') to use an explicit minus sign for negative numbers in the format string. Or we could just duplicate the .IndexOf() call instead of using the msbuild property as an intermediate.

    Any preferences?

    Maybe duplicating would be better. We can use Contains to make a it bit more readable, although it still looks like LISP.

    <_originalTargetOS Condition="$(_originalTargetOS.Contains('.'))">$(_originalTargetOS.SubString(0, $(_originalTargetOS.IndexOf('.'))))</_originalTargetOS>
  11. akoeplinger commented on Feb 16, 2024

    @akoeplinger
    Member

    Yeah I like Contains better too.

  12. ghost added
    in-pr
    on Feb 16, 2024
  13. akoeplinger commented on Feb 16, 2024

    @akoeplinger
    Member
  14. tmds commented on Feb 16, 2024

    @tmds
    Member

    I don't think so, that PR only changes the culture of the Exec task which is not used here.

    I don't suspect that either, though it's a weird coincidence that this is reported with 8.0.200 which is the first SDK to include that change.

    I'm surprised the result of the evaluation depends on the system culture. I had expected msbuild to be using the invariant culture when it evaluates them.

  15. ghost removed
    in-pr
    on Feb 17, 2024
  16. akoeplinger commented on Feb 17, 2024

    @akoeplinger
    Member

    If you export MSBUILDDISABLEFEATURESFROMVERSION=17.10, does it work?

    I tried that and it didn't fix the issue.

    I also tried with an 8.0.100 SDK and it already happens there.

    I'm surprised the result of the evaluation depends on the system culture. I had expected msbuild to be using the invariant culture when it evaluates them.

    Logged dotnet/msbuild#9757 to get some input from the msbuild team.

  17. danmoseley commented on Feb 26, 2024

    @danmoseley
    Contributor

    @rainersigwald

    It looks like <_indexOfPeriod>$(_originalTargetOS.IndexOf('.'))</_indexOfPeriod> causes the int->string conversion to happen with current culture:

    this seems like something MSBuild should consider fixing -- by whatever trick inside the binder. Anything culture-specific by default in a build seems like a bug to me. wdyt?

  18. locked and limited conversation to collaborators on Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions