Closed RamblingCookieMonster closed 8 years ago
+1 on this. I'd like to be able to create "portable" packages with no external dependencies. For ex., if I have a script that uses modules and functions from *.ps1
files, I'd like to build it as one package and have dependecies automatically injected into it via some kind of loader function.
Initial code is in place, but untested. Current state:
# List dependencies, with a DependencyExists column tacked on with the test output
Get-Dependency ... | Test-Dependency
# Check if any dependencies do not exist - quiet switch returns only test result per dependency
( Get-Dependency ... | Test-Dependency -Quiet ) -Contains $False
To do:
Invoke-PSDepend -Test
or Invoke-PSDepend -Import
. I'll likely leave the default behavior to include an install, allowing folks to override, i.e. [bool]$Install = $True
Install
PSDependActionsOn a related note, 'global options' are up and running, where you might specify defaults for certain dependency fields (target, parameters, source, etc.) that you could override on individual dependencies. e.g.:
@{
# Both dependencies below will get these defaults for Target and Parameters
PSDependOptions = @{
Target = 'C:\ProjectX'
Parameters = @{
Force = $True
}
}
BuildHelpers = '0.0.20'
PSDeploy_0_1_21 = @{
DependencyType = 'PSGalleryNuget'
Name = 'PSDeploy'
Version = '0.1.21'
}
}
This might help with tediousness of specifying the same target for every dependency...
Cheers!
Alrighty, the code is in place, and an example of this scenario is documented here.
Still need more thorough testing, but closing this out...
It may be worthwhile to provide functionality to read a depend.psd1 file, install dependencies if they are missing (iffy on this, maybe require a
-Force
), and import supported dependencies (e.g. a PSGalleryModule would be easy to handle)Used in conjunction with options that allow saving to a non-PSModulePath, this could help enable a virtual-environment-lite scenario.