-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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. Most logic can be rewritten in C#.
The dotnet.dsc.resource.json would like something:
{
"$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:
$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 $jsonAdditional 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.