microsoft / winget-dsc

MIT License
23 stars 14 forks source link

Cannot install VS Code extensions using `Microsoft.VSCode.Dsc` #119

Closed Trenly closed 6 days ago

Trenly commented 2 weeks ago

Brief description of your issue

Set() indicates it was successful, but the extensions weren't installed. It only seems to be an issue for installing extensions, as removing them using Exist=$false works. However, even explicitly setting Exist=$true doesn't affect the behavior

Steps to reproduce

Use the configuration file from #117 or run the commands manually -

PS C:\Users\Trenly> Invoke-DscResource -Name VSCodeExtension -ModuleName Microsoft.VSCode.Dsc -Method Get -Property @{Name='redhat.vscode-yaml'}

Name               Version Exist Insiders
----               ------- ----- --------
redhat.vscode-yaml 1.15.0   True    False

PS C:\Users\Trenly> Invoke-DscResource -Name VSCodeExtension -ModuleName Microsoft.VSCode.Dsc -Method Test -Property @{Name='redhat.vscode-yaml'}

InDesiredState
--------------
          True

PS C:\Users\Trenly> Invoke-DscResource -Name VSCodeExtension -ModuleName Microsoft.VSCode.Dsc -Method Get -Property @{Name='EditorConfig.EditorConfig'}

Name                      Version Exist Insiders
----                      ------- ----- --------
EditorConfig.EditorConfig         False    False

PS C:\Users\Trenly> Invoke-DscResource -Name VSCodeExtension -ModuleName Microsoft.VSCode.Dsc -Method test -Property @{Name='EditorConfig.EditorConfig'}

InDesiredState
--------------
         False

PS C:\Users\Trenly> Invoke-DscResource -Name VSCodeExtension -ModuleName Microsoft.VSCode.Dsc -Method set -Property @{Name='EditorConfig.EditorConfig'}

RebootRequired
--------------
         False

PS C:\Users\Trenly> Invoke-DscResource -Name VSCodeExtension -ModuleName Microsoft.VSCode.Dsc -Method test -Property @{Name='EditorConfig.EditorConfig'}

InDesiredState
--------------
         False

Expected behavior

Extensions to be installed

Actual behavior

No Extensions :(

Environment

Running DSC resource directly

Trenly commented 2 weeks ago

[Policy] Issue Bug [Policy] Microsoft.VSCode.Dsc

Gijsreyn commented 2 weeks ago

If you want @Trenly , I can take a look into this?

Trenly commented 2 weeks ago

Please do

Gijsreyn commented 2 weeks ago

I have both Insiders and Stable installed with user installation. I have tested it from my side, but both are working ...

Trenly commented 2 weeks ago

The issue is these lines here: https://github.com/microsoft/winget-dsc/blob/73eabd2c55cb157d30f2420541c3bd7a6e8d68fa/resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1#L98-L102

When an install fails, it may just returns a non-zero exit code instead of throwing an exception. This is what happened on my machine -

Debugging Log

``` Setting 'VSCodeCLIPath' to 'C:\Users\Trenly\AppData\Local\Programs\Microsoft VS Code\bin\code.cmd' Running: & "C:\Users\Trenly\AppData\Local\Programs\Microsoft VS Code\bin\code.cmd" --list-extensions --show-versions Installed Extensions: Name Version ---- ------- eamodio.gitlens 15.6.3 mads-hartmann.bash-ide-vscode 1.43.0 ms-python.debugpy 2024.12.0 ms-python.python 2024.18.0 ms-python.vscode-pylance 2024.11.1 ms-vscode.powershell 2024.4.0 plorefice.devicetree 0.1.1 redhat.vscode-xml 0.27.1 redhat.vscode-yaml 1.15.0 'Set()' function was invoked 'Test()' function was invoked 'Get()' function was invokded Result of 'Get()': Name Version Exist Insiders ---- ------- ----- -------- EditorConfig.EditorConfig False False Desired State: Name Version Exist Insiders ---- ------- ----- -------- EditorConfig.EditorConfig True False Result of 'Test()': InDesiredState -------------- False System was not in desired state, continuing 'Install($false)' was invoked 'Install-VSCodeExtension' was invoked with parameters: Name: EditorConfig.EditorConfig Version: 'Get-VSCodeExtensionInstallArgument' was invoked with parameters: Name: EditorConfig.EditorConfig Version: Result of 'Get-VSCodeExtensionInstallArgument': EditorConfig.EditorConfig 'Invoke-VSCode' was invoked with parameters: Command: --install-extension EditorConfig.EditorConfig Invoking Expression: & "C:\Users\Trenly\AppData\Local\Programs\Microsoft VS Code\bin\code.cmd" --install-extension EditorConfig.EditorConfig Result of 'Invoke-VSCode': Installing extensions... self signed certificate in certificate chain Failed Installing Extensions: editorconfig.editorconfig Returned to 'Install-VSCodeExtension' Installed Extensions: Name Version ---- ------- eamodio.gitlens 15.6.3 mads-hartmann.bash-ide-vscode 1.43.0 ms-python.debugpy 2024.12.0 ms-python.python 2024.18.0 ms-python.vscode-pylance 2024.11.1 ms-vscode.powershell 2024.4.0 plorefice.devicetree 0.1.1 redhat.vscode-xml 0.27.1 redhat.vscode-yaml 1.15.0 Returned to 'Set()' Returned from DSC Resource ```