Skip to content

Conversation

@Gijsreyn
Copy link
Contributor

@Gijsreyn Gijsreyn commented Oct 7, 2024


This pull request introduces a new DSC resource. It allows users to install .NET tools globally.

@Gijsreyn
Copy link
Contributor Author

Gijsreyn commented Oct 7, 2024

@denelon Hi Demitrius, I had gone through the CONTRIBUTING.md, but I was unsure if I had to commit the spec-template file with this PR. Do you want me to include it?

@denelon
Copy link
Collaborator

denelon commented Oct 7, 2024

Yes please. Any additional documentation will be helpful as users become informed about the new resource.

@denelon
Copy link
Collaborator

denelon commented Oct 7, 2024

It might also be interesting to get you connected to some of the dotnet folks to discuss making dotnet.exe DSC v3 capable. I saw you're writing an e-book on DSC v3 in your GitHub profile.

@denelon denelon requested a review from ryfu-msft October 7, 2024 15:56
@denelon
Copy link
Collaborator

denelon commented Oct 7, 2024

We have been discussing a DSC Resource for dotnet recently. I would have thought about using a module name like "Microsoft.dotnet.Dsc" or something like that. I just don't have enough domain knowledge on dotnet to make the best recommendation.

@Gijsreyn
Copy link
Contributor Author

Gijsreyn commented Oct 7, 2024

Yes please. Any additional documentation will be helpful as users become informed about the new resource.

Will do when I have some time. In the meantime, if you have any suggestions or best practices how you want the docs to look like, just give me a headsup :)

@Gijsreyn
Copy link
Contributor Author

Gijsreyn commented Oct 7, 2024

It might also be interesting to get you connected to some of the dotnet folks to discuss making dotnet.exe DSC v3 capable. I saw you're writing an e-book on DSC v3 in your GitHub profile.

Would love that Demitrius. Great challenge to look at. Indeed I am. Currently storing the content from preview.10 and asked Gael to have a review/foreword. Then probably when dsc gets GA, I'll put it fully live.

@Gijsreyn
Copy link
Contributor Author

Gijsreyn commented Oct 7, 2024

We have been discussing a DSC Resource for dotnet recently. I would have thought about using a module name like "Microsoft.dotnet.Dsc" or something like that. I just don't have enough domain knowledge on dotnet to make the best recommendation.

I would recon a naming change. It was just as first thought that popped up.

@denelon
Copy link
Collaborator

denelon commented Oct 7, 2024

RootModule = 'Microsoft.NET.SDK.ToolInstaller.psm1'
ModuleVersion = '0.1.0'
GUID = '2e883e78-1d91-4d08-9fc1-2a968e31009d'
Author = 'Microsoft Corporation'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@denelon - Is there an ownership concept with DSCs similar to Winget packages? How do you ensure the validity of the author and that they have sole ownership?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is an OSS repository, we'd consider PRs from the community, but since this is a Microsoft "package" the resource would require our approval to make sure we're good with the implementation. Anything published to the PowerShell gallery from here would need that validation before we would sign and publish the module.

return $dotNetPath
}

# TODO: when https://github.com/dotnet/sdk/pull/37394 is documented and version is released with option simple use --format=JSON

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linked PR is fixed in 9 it looks like. Were you waiting for 9 to be the default to replace the below code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I forgot I couldn't install the latest preview from the official website. Everytime when I tried downloading, it gives me 0 bytes. When I used winget install Microsoft.DotNet.SDK.Preview, it did. I guess it installs from a different location.

Eventually, I guess we can move the logic to this:

image

But we should also be able to support older versions of the SDK?

process
{
$installArgument = Get-DotNetToolArguments @PSBoundParameters
$arguments = "tool install $installArgument --global --ignore-failed-sources"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are all of the tools you're installing supported on the current runtimes that are installed? if not, there may be issues with running those tools.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with your statement here, however I do think users themselves should be aware what they should install. I know the architecture option is also available to be specified. It can be added later I would say. Let me know your thoughts.

}

Set() {
# TODO: validate for upgrade/update scenarios

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the update model for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's imagine the following scenario. The user has already installed PowerShell version 7.4.4. The user now wants version 7.4.5. The user leaves empty the version property. When the user runs the configuration, it needs to check if 7.4.4 is installed and if so, update it with dotnet tool update. @ryfu-msft Would you agree with such logic, or should we add a boolean parameter to upgrade?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. If a package has a version that does not match the desired version, then this DSC resource should handle updating the package to match the desired state.

It 'Sets desired package with prerelease version' -Skip:(!$IsWindows) {
$parameters = @{
PackageId = 'PowerShell'
Version = '7.2.0-preview.5'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this version of powershell?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not mistaken, the logic of the CLI to install packages is as followed:

  1. Whenever a preview version is higher than the official version, you require the --prerelease parameter to be added without version
  2. When the official version is higher than a preview version, you use the --version parameter to indicate you want to install a prerelease version that is older. Because you want to test for this scenario, I have included an older version of PowerShell. See list:

image

@Gijsreyn
Copy link
Contributor Author

Gijsreyn commented Oct 8, 2024

@denelon In the latest commit, I have added the option for toolsPath. This allows users to choose a directory to install tools towards.

However, the latest pull request for Microsoft.VSCode.DSC, broke the participation on the export because we removed the static method. I asked Mikey for feedback on enabling export for class-based resources directly from PSDesiredStateConfiguration.

I have tried to incorporate as much of what Mikey sketched out in this change. It probably requires updating the Microsoft.VSCode.DSC also if this is the way forward.

P.S. After thinking about it, DotNetDsc would to it for me.

@denelon
Copy link
Collaborator

denelon commented Oct 8, 2024

@denelon In the latest commit, I have added the option for toolsPath. This allows users to choose a directory to install tools towards.

However, the latest pull request for Microsoft.VSCode.DSC, broke the participation on the export because we removed the static method. I asked Mikey for feedback on enabling export for class-based resources directly from PSDesiredStateConfiguration.

I have tried to incorporate as much of what Mikey sketched out in this change. It probably requires updating the Microsoft.VSCode.DSC also if this is the way forward.

P.S. After thinking about it, DotNetDsc would to it for me.

I'd suggest trying with the experimental WinGet feature something like:

winget configure export --Resource Microsoft.dotnet.Dsc -o dotnet.winget to see if the settings get exported.

I know this is brutal with class-based v2 modules, but it gives us another working example and helps pave the way for DSC v3. We're investing into improvements for the export feature to capture all installed packages, Windows Settings, and any DSC v3 resources (soon to be identified in WinGet package manifests).

}

Set() {
# TODO: validate for upgrade/update scenarios
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. If a package has a version that does not match the desired version, then this DSC resource should handle updating the package to match the desired state.

@Gijsreyn
Copy link
Contributor Author

@ryfu-msft Ryan, sorry for the many commits. I had to re-name the module and figure things out with Semantic Versioning. I have tried to prepare the test to run on the ADO agents. Inside the .psd1 file, the LicenseUri and ProjectUri are included. This is more convenient for people to be redirected when they want to do changes. You mind giving it another look and run the pipelines?

Cheers and have a good weekend already.

@ryfu-msft
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Comment on lines 390 to 394
else
{
# Don't want to downgrade scenarios
Throw "The package version cannot be less than the installed version. Please provide a version greater than or equal to the installed version."
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be throwing on a Get() call. I also believe that we should still support downgrade scenarios even if this is not a common scenario. DSC should be able to set any desired state even if that involves downgrading.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check once again. The logic is a bit different. Check out the GitHub issue linked at the function. Not all SDKs have the downgrade option ;)

@Gijsreyn
Copy link
Contributor Author

@denelon I have also sketch out a proposed solution in the sdk repository. I can imagine that it hasn't the highest priority, but if one operation already is exposed, this becoms obsolete.

If there is anyone whiling to participate, my C# knowledge is rusty. A first set up would greatly assist me.

@ryfu-msft
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ryfu-msft
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@ryfu-msft ryfu-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look great! Will work on getting this published to the gallery. Thank you so much for all your hard work on this! 😄

@ryfu-msft ryfu-msft merged commit 39ffbb6 into microsoft:main Oct 22, 2024
4 checks passed
@Gijsreyn
Copy link
Contributor Author

And thanks for all the feedback! Please let me know when you get it published

@denelon
Copy link
Collaborator

denelon commented Oct 22, 2024

@Gijsreyn
Copy link
Contributor Author

@denelon Thanks for letting me know. I'll try to put out some docs tomorrow and spend some love in some upcoming blogs I'm writing. Curious to your thoughts. Cheers.

@denelon
Copy link
Collaborator

denelon commented Oct 22, 2024

@ryfu-msft and I were chatting about the best place to put docs here, and a sample over at https://aka.ms/dsc.yaml inside the Dev Home repository. We could also consider centralizing examples here now that this repository is open to the public. That would allow me to change the redirect to this repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants