-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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" #3887
Comments
I attempted to get a "clean" reproduction using Windows Sandbox. I got this error when running the configuration from a clean state without Visual Studio Code being installed. It looks like the environment variable for the path to "code.exe" hasn't been applied before running the script resource. If I close and reopen PowerShell and run the same configuration again (with Visual Studio Code now in the path), I do get the error you reported from the image above. I put all 3 attached files (you'll need to unzip them) in my "C:\Sandbox" directory and then ran Note: You may need to unblock one or more of the files due to the Mark of the Web being applied. @SteveL-MSFT do you have any ideas on this exception? |
Running $LASTEXITCODE returns a 0, so that's just a warning. |
I updated the configuration to refresh the environment variables for path, and got it to work on the first run without VSCode installed. # yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
###############################################################################
# Attempting to reproduce https://github.com/microsoft/winget-cli/3887 #
###############################################################################
properties:
resources:
- resource: Microsoft.WinGet.DSC/WinGetPackage
id: VSCode
directives:
description: Install Visual Studio Code
allowPrerelease: true
settings:
id: Microsoft.VisualStudioCode
source: winget
- resource: PSDscResources/Script
dependsOn:
- VSCode
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
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
code --install-extension jebbs.plantuml
code --install-extension yzhang.markdown-all-in-one
configurationVersion: 0.2.0 |
This issue isn't related to WinGet Configuration or the "PSDscResources/Script" DSC Resource, so I'm closing it here. I'd suggest trying to isolate the issue either to VSCode or the extension itself. |
Thank you Demitrius for looking into this, think it is definitely an issue with VSCode rather than the actual extensions. Have now got this working using
|
@PShipstone is this for a project configuration at GitHub or just a personal configuration? |
Brief description of your issue
When using
Winget configuration
, aPSDscResources/Script
resource generates an error when runningcode --install-extension
when the extension is not installed. Even though the warning is generated, the vscode extensions do get installed.Steps to reproduce
Ensure the required VSCode extensions are uninstalled.
Create a YAML DSC file, for example:
Expected behavior
The VSCode extentions get installed with no warnings
Actual behavior
The following error is generated
Environment
The text was updated successfully, but these errors were encountered: