DSCResources
DSCResources copied to clipboard
Update vscodeextension module to support user and system based VS Code installs
Why is this change being made? This change addresses bug #25, vscodeextension couldn't installing extensions because the module couldn't determine if the user has vscode installed. This change updates the logic for detecting VS Code installs for user and system based installs. Cli and Zip installs aren't addressed in this change.
More information on VS Code install types:
- Visual Studio Code on Windows: https://code.visualstudio.com/docs/setup/windows
What changed?
- Look for user based VS Code installs in HKCU:
HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*
- Look for system based VS Code installs in HKLM:
HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*
- Use the path provided in registry as the root path for running code.cmd
- Switch from Start-Process to call operator &
- Add more verbose logging
I didn't bump the version of the module in this change. I'm assuming that would be another pull request.
Note: when running the DSC to install an extension if you have a user based install you will need to pass PsDscRunAsCredential in order for the DSC to detect VS Code as the DSC runs as system otherwise and doesn't have access to the users regitry hive.
When running the extension you might see the below message. This message is unrelated to the vscodeextension DSC. This appears to be an issue with libraries VS Code leverages see: https://github.com/microsoft/vscode/issues/82524
How was the change tested?
- Tested user VS Code extension install
- Tested system VS Code extension install
- Tested without VS Code installed
- Tested requesting an install of an already installed extension
Successful execution with the following DSC config (note the use of PsDscRunAsCredential since my install is a user based install):
$SplitParams = @{
Name = 'vscodeextension'
ModuleName = 'vscode'
Method = 'Test'
Property = @{
Name = 'ms-azuretools.vscode-bicep'
Ensure = 'present'
PsDscRunAsCredential = Get-Credential
}
}
$SplitParams = @{
Name = 'vscodeextension'
ModuleName = 'vscode'
Method = 'Set'
Property = @{
Name = 'ms-azuretools.vscode-bicep'
Ensure = 'present'
PsDscRunAsCredential = Get-Credential
}
}