diff --git a/.vsts-ci/linux-daily.yml b/.vsts-ci/linux-daily.yml index e6a5375b0c..14cdcc1372 100644 --- a/.vsts-ci/linux-daily.yml +++ b/.vsts-ci/linux-daily.yml @@ -122,6 +122,9 @@ stages: condition: succeededOrFailed() - pwsh: | + Import-Module .\build.psm1 + Set-CorrectLocale + Import-Module .\tools\ci.psm1 Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json' Invoke-CITest -Purpose UnelevatedPesterTests -TagSet Others @@ -129,6 +132,9 @@ stages: condition: succeededOrFailed() - pwsh: | + Import-Module .\build.psm1 + Set-CorrectLocale + Import-Module .\tools\ci.psm1 Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json' Invoke-CITest -Purpose ElevatedPesterTests -TagSet Others diff --git a/.vsts-ci/templates/nix-test.yml b/.vsts-ci/templates/nix-test.yml index 89c1a39dd4..d9ed3e3571 100644 --- a/.vsts-ci/templates/nix-test.yml +++ b/.vsts-ci/templates/nix-test.yml @@ -64,16 +64,7 @@ jobs: - pwsh: | Import-Module .\build.psm1 -Force - $environment = Get-EnvironmentInformation - $isUbuntu20 = $environment.IsUbuntu -and $environment.IsUbuntu20 - if ($isUbuntu20) { - $env:LC_ALL='en_US.UTF-8' - $env:LANG='en_US.UTF-8' - sudo locale-gen $LANG - sudo update-locale - } - - locale + Set-CorrectLocale Import-Module .\tools\ci.psm1 Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json' diff --git a/build.psm1 b/build.psm1 index 7441f48eb2..bbb98110d2 100644 --- a/build.psm1 +++ b/build.psm1 @@ -3386,3 +3386,23 @@ function New-NugetConfigFile Set-Content -Path (Join-Path $Destination 'nuget.config') -Value $content -Force } + +function Set-CorrectLocale +{ + if (-not $IsLinux) + { + return + } + + $environment = Get-EnvironmentInformation + if ($environment.IsUbuntu -and $environment.IsUbuntu20) + { + $env:LC_ALL = 'en_US.UTF-8' + $env:LANG = 'en_US.UTF-8' + sudo locale-gen $env:LANG + sudo update-locale + } + + # Output the locale to log it + locale +}