Using custom functions through desiredStateConfiguration targetScope does not work
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
**Bicep version**
Bicep CLI version 0.37.4 (27cc8db2ed)
**Describe the bug**
Microsoft DSC v3 implements its own custom functions. For example, to determine the current drive, I could define the following:
```bicep
targetScope = 'desiredStateConfiguration'
resource powerShellAdapter 'PSDesiredStateConfiguration/File@2025-01-07' = {
name: 'Use Bicep to create file'
properties: {
Ensure: 'Present'
Type: 'File'
DestinationPath: '${systemroot()}\\DSC\\config.txt'
Contents: 'This file was created using Bicep extension from DSC.'
}
}
```
Trying to compile this, results in an error:
**To Reproduce**
Grab the example from the [pull request](https://github.com/PowerShell/DSC/pull/806/files) and run `bicep build file_with_condition.dsc.bicep`
**Additional context**
Add any other context about the problem here.
Contributor guide
Research direction
Start by reproducing the issue with the referenced file_with_condition.dsc.bicep and the command bicep build file_with_condition.dsc.bicep. Trace how the compiler handles desiredStateConfiguration targetScope and the systemroot() custom function; done means the example compiles successfully with the expected function call preserved.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100