Skip to content

Commit 8f2fa52

Browse files
authored
Merge pull request #1433 from SteveL-MSFT/featureondemand-resource
Add `Microsoft.Windows/FeatureOnDemandList` resource
2 parents bc9388c + f948764 commit 8f2fa52

22 files changed

+1341
-195
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424
],
2525
"azure-pipelines.1ESPipelineTemplatesSchemaFile": true,
2626
"powershell.codeFormatting.preset": "OTBS"
27-
}
27+
}

resources/dism_dsc/.project.data.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"SupportedPlatformOS": "Windows",
66
"Binaries": ["dism_dsc"],
77
"CopyFiles": {
8-
"Windows": ["optionalfeature.dsc.resource.json"]
8+
"Windows": ["optionalfeature.dsc.resource.json", "featureondemand.dsc.resource.json"]
99
}
1010
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
"$schema": "https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.json",
3+
"description": "Manage Windows Features on Demand (capabilities) using the DISM API.",
4+
"tags": [
5+
"windows",
6+
"dism",
7+
"capability",
8+
"featureondemand",
9+
"fod"
10+
],
11+
"type": "Microsoft.Windows/FeatureOnDemandList",
12+
"version": "0.1.0",
13+
"get": {
14+
"executable": "dism_dsc",
15+
"args": [
16+
"get",
17+
"feature-on-demand"
18+
],
19+
"input": "stdin",
20+
"requireSecurityContext": "elevated"
21+
},
22+
"export": {
23+
"executable": "dism_dsc",
24+
"args": [
25+
"export",
26+
"feature-on-demand"
27+
],
28+
"input": "stdin",
29+
"requireSecurityContext": "elevated"
30+
},
31+
"set": {
32+
"executable": "dism_dsc",
33+
"args": [
34+
"set",
35+
"feature-on-demand"
36+
],
37+
"input": "stdin",
38+
"implementsPretest": false,
39+
"return": "state",
40+
"requireSecurityContext": "elevated"
41+
},
42+
"schema": {
43+
"embedded": {
44+
"$schema": "http://json-schema.org/draft-07/schema#",
45+
"$id": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/resources/Microsoft.Windows/FeatureOnDemandList/v0.1.0/schema.json",
46+
"title": "Windows Feature on Demand",
47+
"description": "Manage Windows Features on Demand (capabilities) using the DISM API. Supports get, set, and export operations.\n\nhttps://learn.microsoft.com/powershell/dsc/reference/microsoft.windows/featureondemandlist/resource\n",
48+
"markdownDescription": "The `Microsoft.Windows/FeatureOnDemandList` resource enables you to manage Windows Features on Demand (capabilities) using the DISM API.\n\n[Online documentation][01]\n\n[01]: https://learn.microsoft.com/powershell/dsc/reference/microsoft.windows/featureondemandlist/resource\n",
49+
"type": "object",
50+
"additionalProperties": false,
51+
"required": [
52+
"capabilities"
53+
],
54+
"properties": {
55+
"_restartRequired": {
56+
"type": "array",
57+
"title": "Restart required",
58+
"description": "Indicates that a system restart is required to complete the state change. Returned by the set operation when DISM reports that a reboot is needed.",
59+
"items": {
60+
"type": "object",
61+
"additionalProperties": true
62+
}
63+
},
64+
"capabilities": {
65+
"type": "array",
66+
"title": "Capabilities",
67+
"description": "An array of Feature on Demand (capability) filters or information objects.",
68+
"items": {
69+
"type": "object",
70+
"additionalProperties": false,
71+
"properties": {
72+
"identity": {
73+
"type": "string",
74+
"title": "Capability identity",
75+
"description": "The identity of the Windows capability (Feature on Demand). Required for get and set operations. For export operation, this is optional and wildcards (*) are supported for case-insensitive filtering."
76+
},
77+
"_exist": {
78+
"type": "boolean",
79+
"title": "Exists",
80+
"description": "Indicates whether the capability exists on the system. Set to false when the requested capability name is not recognized by DISM."
81+
},
82+
"state": {
83+
"type": "string",
84+
"enum": [
85+
"NotPresent",
86+
"UninstallPending",
87+
"Staged",
88+
"Removed",
89+
"Installed",
90+
"InstallPending",
91+
"Superseded",
92+
"PartiallyInstalled"
93+
],
94+
"title": "Capability state",
95+
"description": "The current state of the capability. For set operations, this property is required and only Installed and NotPresent are accepted; other states are returned by get and export operations and are not valid inputs for set."
96+
},
97+
"displayName": {
98+
"type": "string",
99+
"title": "Display name",
100+
"description": "The display name of the capability. Returned by get and export operations. For export, wildcards (*) are supported for case-insensitive filtering."
101+
},
102+
"description": {
103+
"type": "string",
104+
"title": "Description",
105+
"description": "The description of the capability. Returned by get and export operations. For export, wildcards (*) are supported for case-insensitive filtering."
106+
},
107+
"downloadSize": {
108+
"type": "integer",
109+
"title": "Download size",
110+
"description": "The download size of the capability in bytes. Returned by get and export operations."
111+
},
112+
"installSize": {
113+
"type": "integer",
114+
"title": "Install size",
115+
"description": "The install size of the capability in bytes. Returned by get and export operations."
116+
}
117+
}
118+
}
119+
}
120+
}
121+
}
122+
}
123+
}

resources/dism_dsc/locales/en-us.toml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
_version = 1
22

33
[main]
4-
missingOperation = "Missing operation argument"
5-
usage = "Usage: dism_dsc <get|set|export>"
4+
missingArguments = "Missing operation and resource type arguments"
5+
usage = "Usage: dism_dsc <get|set|export> <optional-feature|feature-on-demand>"
66
windowsOnly = "This resource is only supported on Windows"
77
unknownOperation = "Unknown operation '%{operation}'"
8+
unknownResourceType = "Unknown resource type '%{resource_type}'. Expected 'optional-feature' or 'feature-on-demand'"
89
errorReadingInput = "Error reading input: %{err}"
910

1011
[get]
@@ -17,6 +18,25 @@ failedSerializeOutput = "Failed to serialize output: %{err}"
1718
failedParseInput = "Failed to parse input: %{err}"
1819
failedSerializeOutput = "Failed to serialize output: %{err}"
1920

21+
[fod_get]
22+
failedParseInput = "Failed to parse input: %{err}"
23+
capabilitiesArrayEmpty = "Capabilities array cannot be empty for get operation"
24+
identityRequired = "identity is required for get operation"
25+
failedSerializeOutput = "Failed to serialize output: %{err}"
26+
27+
[fod_export]
28+
failedParseInput = "Failed to parse input: %{err}"
29+
failedSerializeOutput = "Failed to serialize output: %{err}"
30+
31+
[fod_set]
32+
failedParseInput = "Failed to parse input: %{err}"
33+
capabilitiesArrayEmpty = "Capabilities array cannot be empty for set operation"
34+
identityRequired = "identity is required for set operation"
35+
stateRequired = "state is required for set operation"
36+
capabilityNotFound = "Capability '%{identity}' was not found on this system"
37+
unsupportedDesiredState = "Unsupported desired state '%{state}'. Supported states for set are: Installed, NotPresent"
38+
failedSerializeOutput = "Failed to serialize output: %{err}"
39+
2040
[set]
2141
failedParseInput = "Failed to parse input: %{err}"
2242
featuresArrayEmpty = "Features array cannot be empty for set operation"
@@ -34,3 +54,8 @@ getFeatureInfoFailed = "DismGetFeatureInfo failed for '%{name}': HRESULT %{hr}"
3454
enableFeatureFailed = "DismEnableFeature failed for '%{name}': HRESULT %{hr}"
3555
disableFeatureFailed = "DismDisableFeature failed for '%{name}': HRESULT %{hr}"
3656
getFeaturesFailed = "DismGetFeatures failed: HRESULT %{hr}"
57+
capabilitiesNotSupported = "Capability operations are not supported on this system. Capability APIs not available in dismapi.dll."
58+
getCapabilitiesFailed = "DismGetCapabilities failed: HRESULT %{hr}"
59+
getCapabilityInfoFailed = "DismGetCapabilityInfo failed for '%{name}': HRESULT %{hr}"
60+
addCapabilityFailed = "DismAddCapability failed for '%{name}': HRESULT %{hr}"
61+
removeCapabilityFailed = "DismRemoveCapability failed for '%{name}': HRESULT %{hr}"

resources/dism_dsc/optionalfeature.dsc.resource.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@
1212
"get": {
1313
"executable": "dism_dsc",
1414
"args": [
15-
"get"
15+
"get",
16+
"optional-feature"
1617
],
1718
"input": "stdin",
1819
"requireSecurityContext": "elevated"
1920
},
2021
"set": {
2122
"executable": "dism_dsc",
2223
"args": [
23-
"set"
24+
"set",
25+
"optional-feature"
2426
],
2527
"input": "stdin",
2628
"implementsPretest": false,
@@ -30,7 +32,8 @@
3032
"export": {
3133
"executable": "dism_dsc",
3234
"args": [
33-
"export"
35+
"export",
36+
"optional-feature"
3437
],
3538
"input": "stdin",
3639
"requireSecurityContext": "elevated"

0 commit comments

Comments
 (0)