DSC icon indicating copy to clipboard operation
DSC copied to clipboard

New subcommand to return resources used in a config and if they exist

Open SteveL-MSFT opened this issue 3 months ago • 5 comments

Summary of the new feature / enhancement

Higher level tools want to help the user install resources that are needed if they don't exist (bootstrapping). It would be useful to have a new subcommand to dsc that simply returns this information since the engine already does this but at runtime.

Proposed technical implementation details (optional)

dsc config analyze resources

We can extend other analyze subcommands in the future as needed.

SteveL-MSFT avatar Sep 27 '25 03:09 SteveL-MSFT

What would the structure of the return data be?

Something like this:

resources:
  - type: Foo/Bar                   # Fully qualified type name
    version: 1.2.3                  # Latest available
    path: .../bar.dsc.resource.json # Path to manifest
    # etc
  - type: Foo.Bar/Baz               # Fully qualified type name
    available: false                # Indicate the resource wasn't found

Or:

resources:
  available:
    - type: Foo/Bar
      # etc
  unavailable:
    - type: Foo.Bar/Baz

Or something else?

Specifically wondering if we should indicate where in the configuration document each resource is used, whether it was defined with a version pin, and so on - in addition to the metadata about discovered resources we may want to return.

michaeltlombardi avatar Sep 29 '25 14:09 michaeltlombardi

Depends on what the higher level tools need and will do with the information. Since this output structure is custom and doesn't have to match what is in the config, we could return the resolveVersion along with the original apiVersion which could indicate a range, for example.

SteveL-MSFT avatar Sep 29 '25 19:09 SteveL-MSFT

Is this the same as https://github.com/PowerShell/DSC/issues/974?

tgauth avatar Oct 06 '25 19:10 tgauth

@tgauth looks like a dupe, but since this has more recent discussion, resolving the older one as dupe

SteveL-MSFT avatar Oct 06 '25 21:10 SteveL-MSFT

WinGet needs the properties (specifically for WinGet/Package) to determine if the installed package would bring the resources that aren't currently there. Properties that are expressions that can be statically resolved would return the value, but expressions using functions that require actual execution won't work and will return null explicitly.

SteveL-MSFT avatar Oct 09 '25 22:10 SteveL-MSFT