dotnet/sdk-container-builds

Add DOTNET_SYSTEM_GLOBALIZATION_INVARIANT environment variable when InvariantGlobalization property is set

marcmognol opened this issue · 3 comments

Proposal

As a developer I expect that environment variable DOTNET_SYSTEM_GLOBALIZATION_INVARIANT is set to true or false in the published container image whenever <InvariantGlobalization> property is set in the csproj file.

Reproduction steps

  1. Create project folder: mkdir test-invariant
  2. Navigate to the new folder: cd test-invariant
  3. Create sample project: dotnet new worker
  4. Add line <InvariantGlobalization>false</InvariantGlobalization> in the PropertyGroup section of the csproj file
  5. Build: dotnet build -c Release
  6. Publish: dotnet publish -c Release /t:PublishContainer
  7. Inspect the generated container image: docker inspect test-invariant

Expected result:

Env variable DOTNET_SYSTEM_GLOBALIZATION_INVARIANT should be set with the correct value.

            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "APP_UID=1654",
                "ASPNETCORE_HTTP_PORTS=8080",
                "DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false",
                "DOTNET_RUNNING_IN_CONTAINER=true",
                "DOTNET_VERSION=8.0.0"
            ],

Actual result:

            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "APP_UID=1654",
                "ASPNETCORE_HTTP_PORTS=8080",
                "DOTNET_RUNNING_IN_CONTAINER=true",
                "DOTNET_VERSION=8.0.0"
            ],

Workaround:

I can add the following in the csproj file and it works like a charm, but the downside is to keep both settings in sync.

<ItemGroup>
  <ContainerEnvironmentVariable Include="DOTNET_SYSTEM_GLOBALIZATION_INVARIANT" Value="false" />
</ItemGroup>

Thanks.

Why do you expect this? This environment variable, the MSBuild switch, and the other mechanisms for setting runtime-level invariant behavior all are controlling the same runtime-level switch. It is redundant to set the environment variable and the MSBuild switch as a result.

Hi @baronfel

Ok. I wasn't aware of this and thought that the environment variable was mandatory.

Thank you very much for this info.
You can close this issue.
Marc

Thanks!