forked from microsoft/winget-pkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathYamlCreate.dsc.yaml
133 lines (131 loc) · 6.07 KB
/
YamlCreate.dsc.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
############################################################################
# Descripion:
# This configuration file is intended to bootstrap the packages which are
# required for the YamlCreate.ps1 script to have full functionality.
# Although the script will do this automatically, the DSC resource is
# provided as an alternative way to do the initial setup and as an example
# or reference for authoring other DSC files.
#
# This configuration also installs Visual Studio Code and related
# extensions as an IDE for easily working with the manifests generated by
# the YamlCreate.ps1 script.
############################################################################
properties:
resources:
########################################################################
# Section: Install VS-Code
########################################################################
- resource: Microsoft.WinGet.DSC/WinGetPackage
id: install-vs-code
directives:
description: Install Microsoft Visual Studio Code
allowPrerelease: true
settings:
id: Microsoft.VisualStudioCode
source: winget
Ensure: Present
- resource: vscode/VSCodeExtension
dependsOn:
- install-vs-code
directives:
description: Install YAML extension for VSCode
allowPrerelease: true
settings:
Name: redhat.vscode-yaml
Ensure: Present
- resource: vscode/VSCodeExtension
dependsOn:
- install-vs-code
directives:
description: Install EditorConfig extension for VSCode
allowPrerelease: true
settings:
Name: EditorConfig.EditorConfig
Ensure: Present
########################################################################
# Section: Install Packages
########################################################################
- resource: Microsoft.WinGet.DSC/WinGetPackage
id: install-git
directives:
description: Install Git # Although the user probably already has git installed, it's possible that they don't
allowPrerelease: true
settings:
id: Git.Git
source: winget
Ensure: Present
- resource: Microsoft.WinGet.DSC/WinGetPackage
id: install-git-cli
directives:
description: Install GitHub CLI
allowPrerelease: true
settings:
id: GitHub.cli
source: winget
Ensure: Present
########################################################################
# Section: Configure Git Remotes
########################################################################
- resource: GitDSC/GitRemote
id: add-microsoft-upstream
directives:
description: Add microsoft/winget-pkgs as the upstream remote
allowPrerelease: true
settings:
ProjectDirectory: '${WinGetConfigRoot}\..'
RemoteName: upstream
RemoteUrl: https://github.com/microsoft/winget-pkgs.git
########################################################################
# Section: Install PowerShell Modules
########################################################################
- resource: PowerShellModule/PSModuleResource
id: install-powershell-yaml
directives:
description: Install powershell-yaml module
allowPrerelease: true
settings:
Module_Name: powershell-yaml
Ensure: Present
########################################################################
# Section: Enable Windows Sandbox
# Note:
# Windows Sandbox isn't available on all editions of Windows, which
# will cause this DSC resource to fail in some cases. It is possible
# to enable the sandbox by manually registering all the containers
# packages with DISM and then use DISM again to enable the Windows
# feature. While DSC is maturing, the script resource has been used
# to check the privelege level and edition of windows before Sandbox
# can be enabled using DSC.
########################################################################
# - resource: Microsoft.WindowsSandbox.DSC/WindowsSandbox
# id: install-windows-sandbox
# directives:
# description: Enable Windows Sandbox
# allowPrerelease: true
# settings:
# Ensure: Present
- resource: PSDscResources/Script
id: install-windows-sandbox
directives:
description: Enable Windows Sandbox
allowPrerelease: true
settings:
GetScript: |
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (!$isAdmin) { return @{Result = 'Dism must be run as admin'}}
@{Result = $((dism /online /Get-Features /Format:Table | Select-String 'Containers-DisposableClientVM').Line.Trim() -split ' ' |Select-Object -Last 1)}
TestScript: |
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
$caption = (Get-CimInstance Win32_OperatingSystem).Caption
$isSandboxApplicable = $caption -match 'Windows (10|11) (Pro|Enterprise|Education)'
if (!$isAdmin -or !$isSandboxApplicable) {return $false}
$((dism /online /Get-Features /Format:Table | Select-String 'Containers-DisposableClientVM').Line.Trim() -split ' ' |Select-Object -Last 1) -eq 'Enabled'
SetScript: |
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
$caption = (Get-CimInstance Win32_OperatingSystem).Caption
$isSandboxApplicable = $caption -match 'Windows (10|11) (Pro|Enterprise|Education)'
if ($isAdmin -and $isSandboxApplicable) {
dism /online /enable-feature /featurename:Containers-DisposableClientVM /norestart
}
configurationVersion: 0.2.0