SynEdgy / Sampler.DscPipeline

DSC Pipeline Helpers and tasks for use with Datum
MIT License
9 stars 9 forks source link

Removed 'RequiredModules' attribute in PSD1 #13

Closed psdgal closed 8 months ago

psdgal commented 2 years ago

Description

This attribute causes to download the latest version of the specified modules (e.g: Plater, Sampler, DscBuildHelpers). This behaviour happens also when someone runs build.ps1 -ResolveDependency, which causes dependency to broke (no matter what specified in RequiredModules.psd1).

In particular, given my RequiredModules.psd1

'Sampler.DscPipeline'        = '0.2.0-preview0001'
DscBuildHelpers              = '0.0.42'

I have got issue because of the new version (0.2.0) of DscBuildHelpers being downloaded, even if I wanted to force 0.0.42 to stay.

Task list


This change is Reviewable

gaelcolas commented 2 years ago

Please share your PSD1, it could be an issue with the order, but I suspect that's because PowerShellGet is "dumb" when it downloads a module, it just downloads all dependencies at once. Removing the code as you've done in your PR is the least favourite thing to do IMO...

Why do you pin this old version of DSCBuildHelpers? Maybe fixing something here would unblock you "more cleanly"

raandree commented 1 year ago

I did just run into the same issue. I am working with a private version of Sampler in a DSC project. I want this private version of Sampler to be used and removed the reference in the RequiredModules.psd1 and changed the .gitignore like this:

output/*
!output/RequiredModules/
output/RequiredModules/*
!output/RequiredModules/Sampler

I expect that Sampler will not be downloaded as a requirement but the version used that is present. However, the bootstrap process always tries to get the latest version from the gallery.

Plaster and Sampler are in any standard RequiredModules.psd1 created by Sampler anyway. Maybe DscBuildHelpers should stay but having Sampler in the list creates kind of a circular dependency.

gaelcolas commented 1 year ago

So far, I'm ok with removing Plaster because it's not directly used by this module and it's already in requiredModules from Sampler, but I guess that's not your issue.

Sampler is absolutely a dependency for Sampler.DscPipeline, and I don't want to remove it from there unfortunately.

The fact that we double-down in the RequiredModules.psd1 and also require Sampler is probably unecessary.

If you have a custom version of Sampler, it should be in your private PS repo and you should pin that version, so that even if PowerShellGet pulls Sampler as a dependeny, it's the right custom version for you.

Alternatively, you also need a custom version of Sampler.DscPipeline and the same thing applies...

Having custom versions of module is wrong... And for sampler, it's weird because you should be able to extend it instead of forking.

Side question, is the new version of PowerShellGet still pulling module dependencies if they're already available in PSModulePath? If not, is it an option to add to Sampler to use PowerShellGetv3?

gaelcolas commented 8 months ago

Discussed @raandree. Direct module dependencies ought to be specified. The only alternative here is to have a task that cleans up undesired versions, before they are loaded. If some features in 0.0.42 are missing, we're happy to discuss adding them back.