Skip to content

Commit

Permalink
Task Set_PSModulePath: Expanding PSModulePath (#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
raandree authored Aug 26, 2024
1 parent e669ffa commit 1e31766
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
6 changes: 5 additions & 1 deletion .build/tasks/SetPsModulePath.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ SetPSModulePath:
RemoveProgramFiles: true
RemoveWindows: false
SetSystemDefault: false
#>

Task Set_PSModulePath {
Expand Down Expand Up @@ -55,6 +54,11 @@ Task Set_PSModulePath {
$param.BuiltModuleSubdirectory = $BuiltModuleSubdirectory
$param.RequiredModulesDirectory = $RequiredModulesDirectory

if ($param.PSModulePath)
{
$param.PSModulePath = $ExecutionContext.InvokeCommand.ExpandString($param.PSModulePath)
}

$newPSModulePath = Set-SamplerPSModulePath @param -PassThru
Write-Build darkGray "`t...The new 'PSModulePath' is '$newPSModulePath'"

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Switch to build worker `windows-latest` for the build phase of the pipeline
due to a issue using `Publish-Module` on the latest updated build worker in
Azure Pipelines.
- Set_PSModulePath: The PSModulePath is now expanded and can therefore also
contain variables.
- Switch to build worker `windows-latest` for the build phase of the pipeline
due to a issue using `Publish-Module` on the latest updated build worker in
Azure Pipelines.
- Public command documentation has been moved from README.md to the GitHub
repository Wiki.
- Update order of deploy tasks for the Plaster templates to make it easier
Expand Down
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1886,11 +1886,26 @@ SetPSModulePath:
SetSystemDefault: false
```

The `PSModulePath` parameter can access variables and contain sub-expressions.

```yaml
####################################################
# Setting Sampler PSModulePath #
####################################################
SetPSModulePath:
PSModulePath: $ProjectPath\.temp\Microsoft Azure AD Sync\Bin;$([System.Environment]::GetFolderPath('ProgramFiles'))\WindowsPowerShell\Modules;$([System.Environment]::GetFolderPath('System'))\WindowsPowerShell\v1.0\Modules
RemovePersonal: false
RemoveProgramFiles: false
RemoveWindows: false
SetSystemDefault: false
```

#### Section SetPSModulePath

##### Property SetPSModulePath
##### Property PSModulePath

Sets the `PSModulePath` to the specified value.
Sets the `PSModulePath` to the specified value. This string is treated like an expandable
string and can access variables and contain sub-expressions.

##### Property RemovePersonal

Expand Down
3 changes: 2 additions & 1 deletion Sampler/Templates/Build/build.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,8 @@ DscResource.DocGenerator:
# Setting Sampler PSModulePath #
####################################################
#SetPSModulePath:
#PSModulePath: C:\Users\Install\OneDrive\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;c:\Users\Install\.vscode\extensions\ms-vscode.powershell-2022.5.1\modules;
#Sub expressions in the PSModulePath are supported but not part of the template as it does not work with Plaster
#PSModulePath: C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;c:\Users\Install\.vscode\extensions\ms-vscode.powershell-2022.5.1\modules;
#RemovePersonal: false
#RemoveProgramFiles: false
#RemoveWindows: false
Expand Down

0 comments on commit 1e31766

Please sign in to comment.