PowerShell / DSC

This repo is for the DSC v3 project
MIT License
133 stars 22 forks source link

Install PowerShell7 resource #417

Open SteveL-MSFT opened 2 months ago

SteveL-MSFT commented 2 months ago

Summary of the new feature / enhancement

A resource that simply installs PowerShell7 (if not already installed, so test should be implemented probably). This solves some bootstrapping scenarios and only require dsc to then get PS7. This would be cross-platform abstracting install of msi/appx/rpm/deb/brew. On non-Windows, it would need to be a Bash script while on Windows, we could still rely on Windows PowerShell.

What we don't support is a way (without an exe) to call different scripts based on the OS. So we either need a small exe that just calls a script appropriate for the OS or add a capability in the resource manifest to do different commands based on the OS (seems like the latter would create more problems to handle many edge cases).

Proposed technical implementation details (optional)

No response

michaeltlombardi commented 2 months ago

I would prefer that DSC not try to handle multi-platform behavior from the manifest, both because is can lead to substantially more complicated manifests and edge case errors, and because I think the better practice and pattern is to use a small executable to select the correct shell script.

Should this resource handle versions, or just always grab the latest stable release? Are there other considerations to account for in the install, like path, or should it just use the defaults?

SteveL-MSFT commented 2 months ago

Was thinking about this and if this resource ships with DSC, then the individual packages (Windows, Linux, macOS) would have their own versions so we don't need to dynamically choose and ship all OS support to every OS. Basically the choice would be in our build process dependent on the host OS.

I think we want channel support (stable, preview, and LTS) but always the latest and probably not support specific version (we can revisit in the future). Initial scenario is for bootstrapping a VM, so we can defer scope (currentUser, allUsers) later.

kilasuit commented 2 months ago

Could this not make use of the install-powershell scripts in the PowerShell repo?

SteveL-MSFT commented 2 months ago

Could this not make use of the install-powershell scripts in the PowerShell repo?

Those scripts were designed for our CI system when PS7 wasn't readily available so not ever intended to be used outside of that environment. At this time, it's probably easier to write the resource from scratch to be honest.

anmenaga commented 3 weeks ago

Looks like Microsoft.WinGet.DSC/WinGetPackage does this:

    - name: PowerShell 7 Preview
      type: Microsoft.WinGet.DSC/WinGetPackage
      properties:
        Id: Microsoft.PowerShell.Preview