Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Winget configuration "PSDscResources/Script" error when running "code --install-extension" #198627

Closed
PShipstone opened this issue Nov 19, 2023 · 1 comment
Assignees

Comments

@PShipstone
Copy link

PShipstone commented Nov 19, 2023

Does this issue occur when all extensions are disabled?: YES

  • VS Code Version:
    image

  • OS Version:

Windows Package Manager (Preview) v1.7.2782-preview
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22631.2506
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.22.2782.0

Brief description of your issue

Ref closed winget issue: microsoft/winget-cli#3887

When using Winget configuration, a PSDscResources/Script resource generates an error when running code --install-extension when the extension is not installed. Even though the warning is generated, the vscode extensions do get installed.

Steps to reproduce

  1. Ensure the required VSCode extensions are uninstalled.

  2. Create a YAML DSC file, for example:

# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
properties:
  resources:      
    - resource: PSDscResources/Script
      id: myAppConfig
      directives:
        description: Configure My App
        allowPrerelease: true
      settings:
        GetScript: |
          # Your custom PowerShell code to check app configuration
        TestScript: |
          return $false
        SetScript: |
          # PowerShell script commands to install VSCode extensions
          code --install-extension jebbs.plantuml 
          code --install-extension yzhang.markdown-all-in-one      
  configurationVersion: 0.2.0 
  1. Execute WinGet, for example:
winget configuration C:\tmp\dev-machine.dsc.yaml

Expected behavior

The VSCode extentions get installed with no warnings

Actual behavior

The following warning is generated, but the extensions are still installed

image

@PShipstone
Copy link
Author

update: I have resolved my problem by using start-process as shown below, but would be nice if the above worked:

    - resource: PSDscResources/Script
      id: VSCode-Extensions
      directives:
        description: Install VSCode extensions
        allowPrerelease: false
      settings:
        GetScript: |
          # Your custom PowerShell code to check app configuration
        TestScript: |
          return $false
        SetScript: |
          # PowerShell script commands to install VSCode extensions
          Start-Process -WindowStyle Hidden code "--install-extension jebbs.plantuml" -Wait
          Start-Process -WindowStyle Hidden code "--install-extension yzhang.markdown-all-in-one" -Wait 

@joaomoreno joaomoreno closed this as not planned Won't fix, can't repro, duplicate, stale Jan 12, 2024
@microsoft microsoft locked and limited conversation to collaborators Jun 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants