Skip to content

BYL5xxx: Build and settings

Reported by Build-Bylaw itself: reading bylaw.json and its parameters, finding and running the .bylaw.ps1 files, and checks across the whole build.

Code Severity Meaning
BYL5001 Error bylaw.json isn't valid
BYL5002 Error Unknown setting
BYL5003 Error Settings file not found
BYL5004 Error Unsupported languageVersion
BYL5005 Error Setting needs a path
BYL5006 Error Invalid definition scope
BYL5007 Error Unknown output format
BYL5010 Error The file failed
BYL5011 Error The file wrote an error
BYL5012 Error The file could not be compiled
BYL5013 Error Param( at the start of a block
BYL5020 Error Name used twice in the build
BYL5021 Warning File with no definitions
BYL5030 Warning Output file not produced by this build
BYL5040 Error Path not found
BYL5041 Error Output folder can't be used

BYL5001

bylaw.json isn't valid (error)

The settings file isn't valid JSON, or isn't a JSON object.

To fix it: Correct the JSON. The file is an object of settings.

For example:

{
  "languageVersion": "1.0",
  "definitionScope": "/providers/Microsoft.Management/managementGroups/contoso"
}

BYL5002

Unknown setting (error)

bylaw.json has a key Bylaw doesn't know, so a misspelled setting fails instead of being ignored. The message suggests the closest key.

To fix it: Use one of languageVersion, aliasCache, roleCache, initiativeOutputPath and definitionScope.

BYL5003

Settings file not found (error)

The file given with -Settings doesn't exist.

To fix it: Correct the path, or leave -Settings out to use the nearest bylaw.json at or above the -Path folder, if there is one.

BYL5004

Unsupported languageVersion (error)

languageVersion pins the language's behaviour, so upgrading Bylaw doesn't change existing output. Only the versions this Bylaw knows are accepted, written as a string.

To fix it: Use a supported version, such as "1.0", in quotes.

See ADR-0012.

BYL5005

Setting needs a path (error)

aliasCache, roleCache and initiativeOutputPath are paths, relative to bylaw.json, and must be non-empty strings.

To fix it: Give the setting a path, e.g. "aliasCache": "./aliases.json", or remove it.

BYL5006

Invalid definition scope (error)

-DefinitionScope and definitionScope are the management group or subscription the build's policies are deployed at, as a resource ID.

To fix it: Use /providers/Microsoft.Management/managementGroups/ or /subscriptions/.

See ADR-0035.

BYL5007

Unknown output format (error)

format in bylaw.json isn't one of the output formats. It sets the format for every build that uses the settings file, as -Format does for one build (ADR-0011).

To fix it: Set format to "PlainJson", the default, or "Epac", spelled as -Format spells it.

For example:

{
  "format": "Epac"
}

See ADR-0011.

BYL5010

The file failed (error)

The .bylaw.ps1 file stopped with an error outside any Policy or Initiative block, for example in code at the top of the file. The message is PowerShell's own.

To fix it: Fix the line the message points to, as in any script.

BYL5011

The file wrote an error (error)

The .bylaw.ps1 file wrote an error outside any Policy or Initiative block without stopping, for example with Write-Error or a command that failed. The build treats it as an error, so problems aren't lost.

To fix it: Fix the cause, or handle the error in the file.

BYL5012

The file could not be compiled (error)

The file couldn't be run at all, for example because it has a syntax error or couldn't be read.

To fix it: Open the file in an editor with PowerShell support, which shows syntax errors, and fix them.

BYL5013

Param( at the start of a block (error)

PowerShell reads Param( at the start of a scriptblock as a parameter declaration, not as the Param keyword, so the file can't be parsed.

To fix it: Write Param Name without brackets, or put the call in parentheses: (Param Name).

For example:

Effect (Param Effect)

BYL5020

Name used twice in the build (error)

Policy and initiative names become definition names and file names, so they must be unique across the build, ignoring case, policies and initiatives together. The message gives the first one.

To fix it: Rename one of them.

See ADR-0013.

BYL5021

File with no definitions (warning)

A .bylaw.ps1 file ran without declaring any Policy or Initiative. It may be a helper file, or the blocks may be missing.

To fix it: Add the definitions, or give a helper file another extension, such as .ps1, and dot-source it.

See ADR-0013.

BYL5030

Output file not produced by this build (warning)

The output folder has a .json file that this build didn't write, usually from a policy that has since been renamed or removed. Bylaw never deletes output.

To fix it: Delete the file if its policy or initiative is gone.

See ADR-0011.

BYL5040

Path not found (error)

A path given to Build-Bylaw -Path doesn't exist.

To fix it: Correct the path. -Path takes files and folders, and folders are searched for *.bylaw.ps1 files.

See ADR-0013.

BYL5041

Output folder can't be used (error)

An output folder given to Build-Bylaw or ConvertTo-Bylaw, with -OutputPath, -InitiativeOutputPath or the settings file's initiativeOutputPath, is an existing file, is on a drive that doesn't exist, or isn't a valid path. It is checked before anything is compiled or converted, so nothing is written. A folder that doesn't exist yet is fine: it is created.

To fix it: Give a folder, or the path of one to create, on a drive that exists. A relative path is relative to the current location.

See ADR-0013.