Skip to content

Fix an error occurs in setDefaultLanguage.ps1 during the creation of an AVD custom image template#835

Open
Phoebe-0319 wants to merge 2 commits into
Azure:masterfrom
Phoebe-0319:user/xianwang/fix-SetDefaultLang-issue
Open

Fix an error occurs in setDefaultLanguage.ps1 during the creation of an AVD custom image template#835
Phoebe-0319 wants to merge 2 commits into
Azure:masterfrom
Phoebe-0319:user/xianwang/fix-SetDefaultLang-issue

Conversation

@Phoebe-0319

Copy link
Copy Markdown
Contributor

Summary

Added a polling wait before Disable-ScheduledTask in SetDefaultLang.ps1, only on Build 22631 (Win11 23H2), only when the language was already installed by InstallLanguagePacks.ps1. This allows the ReconcileLanguageResources task (triggered by the WU+Restart between InstallLanguagePacks and SetDefaultLang) to finish delivering LpCab before the script disables it.

Flow comparison

                    BEFORE FIX (race condition)

InstallLanguagePacks.ps1          SetDefaultLang.ps1
========================          ==================

Disable tasks                     Disable tasks    <-- kills reconcile!
Install-Language ja-JP            "already installed" (skip)
  -> LanguagePacks: None          Set-systempreferreduilanguage
Enable tasks                        -> FAILS! (LpCab not ready)
                                  Enable tasks
        |
   WU + Restart
   (reconcile starts here,
    may or may not finish
    before SetDefaultLang)
                    AFTER FIX (deterministic)

InstallLanguagePacks.ps1          SetDefaultLang.ps1
========================          ==================

Disable tasks                     [23H2 only] Poll Get-InstalledLanguage
Install-Language ja-JP              until LanguagePacks != None
  -> LanguagePacks: None            (max 600s, 15s interval)
Enable tasks                      Disable tasks    <-- safe, reconcile done
                                  "already installed" (skip)
        |                         Set-systempreferreduilanguage
   WU + Restart                     -> SUCCESS (LpCab ready)
   (reconcile runs here)          Enable tasks
Timeline:

InstallLanguagePacks.ps1                    SetDefaultLang.ps1
    |                                           |
    |  Disable tasks                            |
    |  Install-Language (LanguagePacks=None)     |
    |  Enable tasks                             |
    |                                           |
    +------ WU + Restart ---------------------->|
    |       ^                                   |
    |       | reconcile task starts here        |
    |       | (triggered by restart)            |
    |       |                                   |
    |       | downloading LpCab...              | [NEW] Check: is LanguagePacks
    |       | downloading LpCab...              |        still "None"?
    |       | LpCab ready!                      |        YES -> wait 15s, retry
    |       v                                   |        ...
    |                                           |        YES -> wait 15s, retry
    |                                           |        NO  -> LpCab ready!
    |                                           |
    |                                           | Disable tasks (safe now)
    |                                           | "already installed" branch
    |                                           | Set-systempreferreduilanguage -> OK
    |                                           | Copy-UserInternationalSettings -> OK
    |                                           | Enable tasks
    |                                           |

Scope of change

  • Only affects Win11 23H2 (Build 22631) -- all other OS versions skip the new code entirely
  • Only polls when language was already installed by InstallLanguagePacks.ps1 -- if language is not installed, skips the wait
  • Read-only polling -- uses Get-InstalledLanguage (no side effects)
  • Max wait 600s (10 min) -- if reconcile doesn't finish, proceeds anyway with a WARNING log
  • Zero impact on successful builds -- if reconcile already finished during WU+Restart, first poll returns ready, 0s added

Phoebe-0319 and others added 2 commits June 3, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant