prevent early resolving of Powershell variables by using .NET Combine#126
prevent early resolving of Powershell variables by using .NET Combine#126stehlih wants to merge 3 commits into
Conversation
|
The combine usually does not play well with psdrive. |
|
In the Powershell documentation I found the note: But in the ResolutionPrecedence only the childpath is prepared. The problem is the use of the following code: which produce the following error: Drive doesn't exist. A drive with name "Roles..." was not found. Join-Path : Das Laufwerk wurde nicht gefunden. Ein Laufwerk mit dem Namen "Roles$($ro=$Node.Role.Split('_');
After drop of this part Join-Path works without errors. But I can't found a working replacement to get the value of an environment variable which is required to build the right YAML file name. |
|
@gaelcolas, remember. When going through the code we were not sure why we replaces Besides in Pester tests, when are we dealing with PSDrives other then the normal file drives? |
|
@gaelcolas, I don't see a reason why we should stick to When trying to do something similar like @stehlih, I get this error: I have assigned a value to an environment variable: $env:DscBaseline = 'DscLcm'and used it in the ResolutionPrecedence:
- AllNodes\$($Node.Environment)\$($Node.NodeName)
- Environment\$($Node.Environment)
- Locations\$($Node.Location)
- Roles\$($Node.Role)
- Baselines\Security
- Baselines\$($Node.Baseline)
- Baselines\$($env:DscBaseline)Everything works fine with the proposed change. |
… instead of Join-Path
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@Gael, shall we close this PR or merge it? In case we merge it, I would add a changelog entry in a separate PR. |
prevent early resolving of Powershell variables by using .NET Combine instead of Join-Path
We are using code like the follwoing in the datum.yml:
ResolutionPrecedence:
...
...
In this case the original Join-Path produces an runtime error (illegal path) which can be avoid by using the .NET Combine.