dotnet / dotnet/sdk

Participate `dotnet tool` as first-class resource for DSC operations

Open
#44,325 3 comments 2 reactions 2 assignees Claimed by @MiYanni View on GitHub
Area-Tools
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Is your feature request related to a problem? Please describe.
It would be pretty cool to see `dotnet tool` participate as a first-class resource for DSC operations.

### Describe the solution you'd like
Dotnet tool is not only used by developers. The list has grown overtime, reaching a great number of 5000+ .NET tools available for others roles to be installed.

Bringing in `dotnet tool` to DSC, brings in the flavor of desired state known to roles that are familiar using scripting tools. To sketch out a rough outline of the solution, I would like to see a new command added to `dotnet tool`. This would be `dotnet tool config` including subcommands:

- Get
- Set
- Test (optionally, might be able to use synthetic test)
- Export
- Delete
- WhatIf

Lastly, having a schema command available, would bring in the following command: `dsc tool schema`.

There is already a PowerShell DSC class-based DSC resource currently in [pull request](https://github.com/microsoft/winget-dsc/pull/63). Most logic can be rewritten in C#.

The `dotnet.dsc.resource.json` would like something:

```json
{
"$schema": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/bundled/resource/manifest.json",
"type": "Microsoft.Dotnet.Sdk/DotnetToolCLI",
"description": "Manage Dotnet Tool packages",
"tags": [
"Windows",
"MacOs",
"Linux"
],
"version": "0.1.0",
"get": {
"executable": "dotnet",
"args": [
"config",
"get",
{
"jsonInputArg": "--input",
"mandatory": true
}
]
},
"set": {
"executable": "dotnet",
"args": [
"config",
"set",
{
"jsonInputArg": "--input",
"mandatory": true
}
]
},
"delete": {
"executable": "dotnet",
"args": [
"config",
"delete",
{
"jsonInputArg": "--input",
"mandatory": true
}
]
},
"whatIf": {
"executable": "dotnet",
"args": [
"config",
"set",
"-w",
{
"jsonInputArg": "--input",
"mandatory": true
}
],
"return": "state"
},
"exitCodes": {
"0": "Success",
"1": "Invalid parameter",
"2": "Invalid input",
"3": "Dotnet error",
"4": "JSON serialization failed"
},
"schema": {
"command": {
"executable": "dotnet",
"args": [
"schema"
]
}
}
}
```

The following are examples to input data:

```powershell
$in = @{
PackageId = 'GitVersion.Tool'
}

$json = $in | ConvertTo-Json
dotnet tool config get --input $json

$in = @{
PackageId = 'GitVersion.Tool'
ToolPathDirectory = 'C:\tools'
Version = '6.0.3'
}
$json = $in | ConvertTo-Json
dotnet tool config set --input $json
```

### Additional context
DSC allows operations to be exposed incrementally. It would be pretty awesome to see the .NET team working together and be the first one adopting the new vision of DSC.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.