microsoft / microsoft/devcenter-catalog

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

Open
#70 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PowerShell
Stars
52
Forks
194
Avg merge
16h 53m
Merged PRs (30d)
1

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the setupTasks sequence on the Windows 11+ Optimizations 23H2 image, focusing on the winget tasks with runAsUser enabled. Inspect C:\devboxcustomizations\runAsUser.ps1 and the Repair-WinGetPackageManager invocation, then compare them with the manually successful repair. Done means the runAsUser winget tasks install VSCode and Python during provisioning.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.