Closed PiggiesGoSqueal closed 2 years ago
If there is not a way I figured out how to do it with PowerShell. However, I'd prefer it is done automatically when I build my module.
Here's my workaround:
$computerToolKitPath = "C:\Users\User\Desktop\Test\old.txt"
$newComputerSetupPath = "C:\Users\User\Desktop\Test\new.txt"
"# ---------- Start of ComputerToolKit.psm1 ---------- # `n " +
( (Get-Content $computerToolKitPath) -join "`n" ) +
"`n# ---------- End of ComputerToolKit.psm1 ---------- # `n`n" +
( (Get-Content $newComputerSetupPath) -join "`n" ) |
Set-Content "$newComputerSetupPath"
If you have those 2 modules using ModuleBuilder, why are they in PSM1? is that after each module is built? If that's the that case, why the need to merge them? As per good practice, both of those modules ought to be on a PSGallery, even if it's a private one.
It sounds like you have a "delivery" issue (trying to send something as a single script) that should be fixed by a PSGallery (install/save module from gallery, maybe with a RequiredModules
dependency in the Module manifet of one of those)...
If you have those 2 modules using ModuleBuilder, why are they in PSM1? is that after each module is built? If that's the that case, why the need to merge them? As per good practice, both of those modules ought to be on a PSGallery, even if it's a private one.
It sounds like you have a "delivery" issue (trying to send something as a single script) that should be fixed by a PSGallery (install/save module from gallery, maybe with a
RequiredModules
dependency in the Module manifet of one of those)... Apologies for my late reply. Thanks for your feedback!
Yes, I have 2 modules. ComputerToolKit has many .ps1 files and the .psm1 is only after it is built. NewComputerSetup is currently only one file but I wanted to have ComputerToolKit's .psm1 functions moved to the same .psm1 file for NewComputerSetup so that I could use them on an RMM solution without issues. Yes, I am trying to send something as a single script.
As far as I've seen, it is not possible to create a private PSGallery repository. Do you know of any guide links for this?
Also I'm re-evaluating how I do things a bit hence my late reply.
Check out what I did in RequiredModules/build.ps1 to make the single Install-RequiredModule.ps1
script out of a module (including it's binary dependencYy!)
I actually thought about including Compress-Module
in module builder, just because of how much smaller it makes the module. It loads slightly slower (although it could be modified to expand and cache the file on disk, I suppose), but it's really handy for the single file and the iex (irm ...)
scenario....
However, running your own PSGallery is easy. Check out ProGet, they have a free version...
First off, thank you so much for creating this project. It is very helpful.
Secondly, I have 2 modules that are using ModuleBuilder:
I'd like the functions of both modules to be in one .psm1 file to prevent issues when I copy/paste it to our RMM solution. Note neither of these modules are on PS Gallery.
In the NewComputerSetup module manifest I tried specifying the below but it did not work: RequiredModules = @('\\Source\ComputerToolKit.psd1')
I also tried: RequiredModules = @('ComputerToolKit')
Resources I've Checked I've been reading through the Github pages for this Project and have been using get-help Build-Module but I'm not seeing a solution.
If someone would be willing to help me I'd greatly appreciate some feedback! Thank you!