microsoft / devcenter-catalog

MIT License
26 stars 78 forks source link

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

Open luxu-ms opened 5 months ago

luxu-ms commented 5 months ago

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
  2. 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
  3. 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):

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