-
Notifications
You must be signed in to change notification settings - Fork 0
/
dotnet-configuration.dsc.yaml
135 lines (120 loc) · 5.51 KB
/
dotnet-configuration.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
134
135
# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
##########################################################################################################
# This configuration will install the tools necessary to get started developing in dotnet #
# NOTE: Run: winget configure .\dotnet-configuration.dsc.yaml --accept-configuration-agreements #
##########################################################################################################
properties:
configurationVersion: 0.2.0
resources:
- resource: Microsoft.WinGet.DSC/WinGetPackage
id: DotNetSDK8
directives:
description: Install Microsoft .NET SDK 8.0
allowPrerelease: true
settings:
id: Microsoft.DotNet.SDK.8
source: winget
- resource: Microsoft.WinGet.DSC/WinGetPackage
id: VisualStudio
directives:
description: Install Visual Studio 2022 Enterprise
allowPrerelease: true
settings:
id: Microsoft.VisualStudio.2022.Enterprise
source: winget
- resource: Microsoft.VisualStudio.DSC/VSComponents
directives:
description: Install required VS workloads from project .vsconfig file
allowPrerelease: true
settings:
productId: Microsoft.VisualStudio.Product.Enterprise
channelId: VisualStudio.17.Release
vsConfigFile: '${WinGetConfigRoot}\.vsconfig'
dependsOn:
- VisualStudio
- resource: Microsoft.WinGet.DSC/WinGetPackage
id: VisualStudioCode
directives:
description: Install Visual Studio Code
allowPrerelease: true
settings:
id: Microsoft.VisualStudioCode
source: winget
- resource: PSDscResources/Script
id: VisualStudioCode Extensions
directives:
description: Script to install Visual Studio Code extensions
allowPrerelease: true
settings:
GetScript: |
# Not using this at the moment.
TestScript: |
# Ignore deprecation warnings & reload path
$env:NODE_OPTIONS="--no-deprecation"
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
# Load required extensions from JSON file
$jsonContent = Get-Content '${WinGetConfigRoot}\dotnet-configuration-vscode-extensions.json' -Raw
$extensions = (ConvertFrom-Json $jsonContent).extensions
# Get the list of currently installed extensions
$installedExtensions = code --list-extensions
# Check if all required extensions are installed
$allInstalled = $extensions.name | ForEach-Object { $_ -in $installedExtensions }
return $allInstalled -contains $false -eq $false
SetScript: |
# Ignore deprecation warnings & reload path
$env:NODE_OPTIONS="--no-deprecation"
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
# Load required extensions from JSON file
$jsonContent = Get-Content '${WinGetConfigRoot}\dotnet-configuration-vscode-extensions.json' -Raw
$extensions = (ConvertFrom-Json $jsonContent).extensions
# Get the list of currently installed extensions
$installedExtensions = code --list-extensions
# Install each extension if not already installed
foreach ($extension in $extensions) {
if ($installedExtensions -notcontains $extension.name) {
code --install-extension $extension.name
}
}
dependsOn:
- VisualStudioCode
- resource: PSDscResources/Script
id: DotNetTools
directives:
description: Script to manage .NET tools installation
allowPrerelease: true
settings:
GetScript: |
# Not using this at the moment.
TestScript: |
# Load required tools from JSON file
$jsonContent = Get-Content '${WinGetConfigRoot}\dotnet-tools-configuration.json' -Raw
$requiredTools = (ConvertFrom-Json $jsonContent).tools.id
# Get the list of currently installed global tools
$installedTools = dotnet tool list -g | Select-Object -Skip 2 | ForEach-Object { ($_ -split '\s+')[0] }
# Check if all required tools are installed
$allInstalled = $true
foreach ($toolId in $requiredTools) {
if (-not ($installedTools -contains $toolId)) {
$allInstalled = $false
break
}
}
return $allInstalled
SetScript: |
# Load required tools from JSON file
$jsonContent = Get-Content '${WinGetConfigRoot}\dotnet-tools-configuration.json' -Raw
$tools = (ConvertFrom-Json $jsonContent).tools
# Get the list of currently installed global tools by parsing the first column
$installedTools = dotnet tool list -g | Select-Object -Skip 2 | ForEach-Object { ($_ -split '\s+')[0] }
foreach ($tool in $tools) {
$toolId = $tool.id
$toolVersion = $tool.version
# Install the tool if it is not already installed
if (-not ($installedTools -contains $toolId)) {
$installCommand = "dotnet tool install -g $toolId"
if ($toolVersion -ne "latest") {
$installCommand += " --version $toolVersion"
}
Invoke-Expression $installCommand
}
}