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

VSCodeInstaller DSC class-based resource #75

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# $schema=https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json

########################################################################################
# This configuration will install Visual Studio Code Insiders. #
# PowerShell module: Microsoft.Dotnet.Dsc (v0.1.1-alpha) #
# NOTE: Only Windows is supported. #
########################################################################################

$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
metadata:
Microsoft.DSC:
requiredSecurityContext: Elevated # Required to install software from stable-system
resources:
resources:
- name: IsWindows
type: Microsoft/OSInfo
properties:
family: Windows
- name: Use class PowerShell resources
type: Microsoft.DSC/PowerShell
properties:
resources:
- name: Visual Studio Code Insiders
type: Microsoft.VSCode.Dsc/VSCodeInstaller
properties:
Insiders: true
dependsOn:
- "[resourceId('Microsoft.DSC/Assertion','IsWindows')]"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
configuration InstallVSCodeInsiders
{
Import-DscResource -ModuleName 'Microsoft.VSCode.Dsc'

Node localhost
{
VSCodeInsiders InstallVSCodeInsiders
{
Insiders = $true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2

########################################################################################
# This configuration will install Visual Studio Code Insiders. #
# PowerShell module: Microsoft.Dotnet.Dsc (v0.1.1-alpha) #
########################################################################################

properties:
resources:
- resource: Microsoft.VSCode.Dsc/VSCodeInstaller
directives:
description: Install Visual Studio Code Insiders
allowPrerelease: true
settings:
Insiders: true
configurationVersion: 0.2.0
55 changes: 55 additions & 0 deletions doc/sampleConfigurations/DscResources/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Sample configurations for specific DSC resources

The sample configurations provided in this directory showcase how to create configuration documents both for DSC and WinGet. It's up to you to decide which tool you want. To use DSC, follow the prerequisites. WinGet is included in:

- Windows 10 Version 1809 and later
- Windows 11

Earlier versions of Windows 10 can use the Microsoft Store to download the App Installer package.

## Prerequisites

- [Desired State Configuration - v3.0.0-preview.10+](https://github.com/PowerShell/DSC/tags)
- [PSDesiredStateConfiguration - v2.0.7](https://www.powershellgallery.com/packages/PSDesiredStateConfiguration/2.0.7)

## Getting started

To test out each sample configuration, you only need a PowerShell terminal session. In the sample name, you should find the relevant tool belonging to which tool. To illustrate, see the following example:

```powershell
# Use WinGet
winget configure --file InstallVSCodeInsiders.winget.document.yaml # Use --accept-configuration-agreements to ignore prompt messages

# Use `dsc.exe`
dsc config set --path InstallVSCodeInsiders.winget.document.yaml

# Use PSDesiredStateConfiguration
Start-DscConfiguration -Path InstallVSCodeInsider.ps1 -Force
```

If you don't want to use a _configuration document_, you can always invoke it using `Invoke-DscResource` command. If you inspect the module file, move examples will be found how to use it with the `Invoke-DscResource` command.

## Resources

### GitDsc

### Microsoft.DotNet.Dsc

### Microsoft.VSCode.Dsc

Supports multiple resources to install and work with Visual Studio Code. The following resources can be used:

- **VSCodeExtension:** DSC resource allowing you to install, update, and remove Visual Studio Code extensions. This resource ensures that the specified Visual Studio Code extension is in the desired state.
- **VSCodeInstaller:** DSC resource allowing you to install, update, and remove Visual Studio Code. This resource ensures that the specified version of Visual Studio Code is in the desired state.

## Microsoft.Windows.Developer

### Microsoft.Windows.Setting.Accessibility

### Microsoft.WindowsSandbox.DSC

### NpmDsc

### PythonPip3Dsc

### YarnDsc
6 changes: 4 additions & 2 deletions resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
Description = 'DSC Resource for Visual Studio Code'
PowerShellVersion = '7.2'
DscResourcesToExport = @(
'VSCodeExtension'
'VSCodeExtension',
'VSCodeInstaller'
)
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
Tags = @(
'PSDscResource_VSCodeExtension'
'PSDscResource_VSCodeExtension',
'PSDscResource_VSCodeInstaller'
)

# Prerelease string of this module
Expand Down
Loading