Skip to content

Winget runasuser task cannot work correctly with the image Win11+optimized OS #70

@luxu-ms

Description

@luxu-ms

Describe the bug
If we created the dev pool with the image Windows 11+ Optimizations 23H2, then upload the yaml below,
After the dev box is provisioned, VSCode and Python are not installed.

Note: we also used Windows 11 + VS2022 (including PowerShell7), VSCode and Python are installed.

To Reproduce
Steps to reproduce the behavior:

  1. Create the dev box pool using the image
image
  1. Create the dev box in the dev portal, using the customization file below:
    `
    setupTasks:
  • task: powershell
    inputs:
    command: |
    "New-Item -Type Directory -Path 'c:\' -Name qt-custom"
  • task: winget
    inputs:
    package: Microsoft.VisualStudioCode
    runAsUser: true
  • task: winget
    inputs:
    package: Python.Python.3.11
    runAsUser: true
  • task: winget
    inputs:
    package: Amazon.AWSCLI
  • task: winget
    inputs:
    package: RubyInstallerTeam.Ruby.3.2
  • task: winget
    inputs:
    package: Oracle.JDK.17
  • task: powershell-runas
    inputs:
    command: '& "$env:LOCALAPPDATA\Programs\Microsoft VS Code\bin\code" --install-extension github.copilot'
    runAsUser: true
    `
    please check the snapshot, the code above is changed by markdown
image
  1. Login to dev box, wait for the popped PowerShell windows to execute

Expected behavior
VSCode and Python should be installed.

Screenshots
In the C:\devboxcustomizations, runAsUser.ps1 is as below, it looks ok:
image
But when execute the command, it give the error
image

After we manually execute the repair code, it can install VSCode.
image

So the issue is that when the task schedule launched the PowerShell, even in the script, there is the command Repair-WinGetPackageManager, but it cannot be executed successfully.

Dev Box VM Details (please complete the following information):

  • OS version: Windows 11+ Optimizations 23H2

Additional context
by the way, Amazon CLI and JDK are installed because it's executed under system role

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions