UTF8wBOM not preserved wich causes build to fail
- Dominant language
- PowerShell
- Stars
- 243
- Forks
- 46
- Avg merge
- 1h 41m
- Merged PRs (30d)
- 1
Description
### Problem description
When I need to use `UTF8wBOM` for one of my script files in source, the resulting `.psm1` in `output` is created as `UTF-8` only which causes some parts of the build to fail.
## Steps to reproduce
* Create a new SimpleModule
~~~
$samplerModule = Import-Module -Name Sampler -PassThru
$invokePlasterParameters = @{
TemplatePath = Join-Path -Path $samplerModule.ModuleBase -ChildPath 'Templates/Sampler'
DestinationPath = '.\'
ModuleType = 'SimpleModule'
ModuleName = 'UTFwBOM8'
ModuleAuthor = 'DennisL'
ModuleDescription = 'Demonstrate an issue with UTF8 swedish'
}
Invoke-Plaster @invokePlasterParameters
~~~
* Edit the sample file `Get-Something.ps1` to include a swedish character
~~~
process
{
Wrtite-Verbose 'This is Ä' #This line only had been added
if ($pscmdlet.ShouldProcess($Data))
{
Write-Verbose -Message ('Returning the data: {0}' -f $Data)
Get-PrivateFunction -PrivateData $Data
}
else
{
Write-Verbose -Message 'oh dear'
}
}
~~~
* Save the sample file as `UTF-8 with BOM` tp preserve swedish characters output and handling
* Build the project to induce the error
~~~
.\build.ps1
~~~
## Steps the mitigate the issue
After each build, the `.psm1` file in the `output` folder has to be resaved as `UTF-8 with BOM`.
## Desired behavior
If any source file or the source `.psm1` is saved using `UTF-8 with BOM`, the resulting `.psm1` in `output` must also be saved as `UTF-8 with BOM` or else a module import will fail.
### Verbose logs
```text
The output is 96 439 characters long and won't fit in the form.
```
### Suggested solution
_No response_
### Environment
```text
~~~
WindowsBuildLabEx : 26100.1.amd64fre.ge_release.240331-1435
WindowsCurrentVersion : 6.3
WindowsEditionId : ServerStandard
WindowsInstallationType : Server
WindowsInstallDateFromRegistry : 2026-01-08 12:39:27
WindowsProductId : 00492-90000-00001-AA131
WindowsProductName : Windows Server 2025 Standard
WindowsRegisteredOrganization : My Company
WindowsRegisteredOwner : My Company
WindowsSystemRoot : C:\WINDOWS
WindowsVersion : 2009
OSDisplayVersion : 24H2
BiosCharacteristics : {4, 7, 9, 11...}
BiosBIOSVersion : {INTEL - 6040000, VMW201.00V.24224532.B64.2408191502, VMware
, Inc. - 10000}
BiosBuildNumber :
BiosCaption : VMW201.00V.24224532.B64.2408191502
BiosCodeSet :
BiosCurrentLanguage :
BiosDescription : VMW201.00V.24224532.B64.2408191502
BiosEmbeddedControllerMajorVersion : 255
BiosEmbeddedControllerMinorVersion : 255
BiosFirmwareType : Uefi
BiosIdentificationCode :
BiosInstallableLanguages :
BiosInstallDate :
BiosLanguageEdition :
BiosListOfLanguages :
BiosManufacturer : VMware, Inc.
BiosName : VMW201.00V.24224532.B64.2408191502
BiosOtherTargetOS :
BiosPrimaryBIOS : True
BiosReleaseDate : 2024-08-19 02:00:00
BiosSeralNumber : VMware-42 04 06 6d 5e b9 79 14-98 3c 1c 43 04 a9 fd ff
BiosSMBIOSBIOSVersion : VMW201.00V.24224532.B64.2408191502
BiosSMBIOSMajorVersion : 2
BiosSMBIOSMinorVersion : 7
BiosSMBIOSPresent : True
BiosSoftwareElementState : Running
BiosStatus : OK
BiosSystemBiosMajorVersion : 255
BiosSystemBiosMinorVersion : 255
BiosTargetOperatingSystem : 0
BiosVersion : INTEL - 6040000
CsAdminPasswordStatus : Enabled
CsAutomaticManagedPagefile : True
CsAutomaticResetBootOption : True
CsAutomaticResetCapability : True
CsBootOptionOnLimit : DoNotReboot
CsBootOptionOnWatchDog : DoNotReboot
CsBootROMSupported : True
CsBootStatus : {0, 0, 0, 33...}
CsBootupState : Normal boot
CsCaption : V-MGMT-HD
CsChassisBootupState : Safe
CsChassisSKUNumber :
CsCurrentTimeZone : 120
CsDaylightInEffect : True
CsDescription : AT/AT COMPATIBLE
CsDNSHostName : V-MGMT-HD
CsDomain : my.company.com
CsDomainRole : MemberServer
CsEnableDaylightSavingsTime : True
CsFrontPanelResetStatus : Unknown
CsHypervisorPresent : True
CsInfraredSupported : False
CsInitialLoadInfo :
CsInstallDate :
CsKeyboardPasswordStatus : Unknown
CsLastLoadInfo :
CsManufacturer : VMware, Inc.
CsModel : VMware20,1
CsName : V-MGMT-HD
CsNetworkAdapters : {Ethernet0}
CsNetworkServerModeEnabled : True
CsNumberOfLogicalProcessors : 4
CsNumberOfProcessors : 2
CsProcessors : {Intel(R) Xeon(R) Gold 6140 CPU @ 2.30GHz, Intel(R) Xeon(R) G
old 6140 CPU @ 2.30GHz}
CsOEMStringArray : {[MS_VM_CERT/SHA1/27d66596a61c48dd3dc7216fd715126e33f59ae7],
Welcome to the Virtual Machine}
CsPartOfDomain : True
CsPauseAfterReset : 3932100000
CsPCSystemType : Desktop
CsPCSystemTypeEx : Desktop
CsPowerManagementCapabilities :
CsPowerManagementSupported :
CsPowerOnPasswordStatus : Disabled
CsPowerState : Unknown
CsPowerSupplyState : Safe
CsPrimaryOwnerContact :
CsPrimaryOwnerName : My Company
CsResetCapability : Other
CsResetCount : -1
CsResetLimit : -1
CsRoles : {LM_Workstation, LM_Server, NT, Server_NT}
CsStatus : OK
CsSupportContactDescription :
CsSystemFamily :
CsSystemSKUNumber :
CsSystemType : x64-based PC
CsThermalState : Safe
CsTotalPhysicalMemory : 8588939264
CsPhyicallyInstalledMemory : 8388608
CsUserName :
CsWakeUpType : PowerSwitch
CsWorkgroup :
OsName : Microsoft Windows Server 2025 Standard
OsType : WINNT
OsOperatingSystemSKU : StandardServerEdition
OsVersion : 10.0.26100
OsCSDVersion :
OsBuildNumber : 26100
OsHotFixes : {KB5082417, KB5094125, KB5094137}
OsBootDevice : \Device\HarddiskVolume1
OsSystemDevice : \Device\HarddiskVolume4
OsSystemDirectory : C:\WINDOWS\system32
OsSystemDrive : C:
OsWindowsDirectory : C:\WINDOWS
OsCountryCode : 1
OsCurrentTimeZone : 120
OsLocaleID : 0409
OsLocale : en-US
OsLocalDateTime : 2026-08-05 17:36:56
OsLastBootUpTime : 2026-07-28 15:02:31
OsUptime : 8.02:34:25.2947037
OsBuildType : Multiprocessor Free
OsCodeSet : 1252
OsDataExecutionPreventionAvailable : True
OsDataExecutionPrevention32BitApplications : True
OsDataExecutionPreventionDrivers : True
OsDataExecutionPreventionSupportPolicy : OptOut
OsDebug : False
OsDistributed : False
OsEncryptionLevel : 256
OsForegroundApplicationBoost : Maximum
OsTotalVisibleMemorySize : 8387636
OsFreePhysicalMemory : 1916452
OsTotalVirtualMemorySize : 9763892
OsFreeVirtualMemory : 2625876
OsInUseVirtualMemory : 7138016
OsTotalSwapSpaceSize :
OsSizeStoredInPagingFiles : 1376256
OsFreeSpaceInPagingFiles : 428340
OsPagingFiles : {C:\pagefile.sys}
OsHardwareAbstractionLayer : 10.0.26100.32860
OsInstallDate : 2026-01-08 13:39:27
OsManufacturer : Microsoft Corporation
OsMaxNumberOfProcesses : 4294967295
OsMaxProcessMemorySize : 137438953344
OsMuiLanguages : {en-US}
OsNumberOfLicensedUsers : 0
OsNumberOfProcesses : 241
OsNumberOfUsers : 89
OsOrganization : My Company
OsArchitecture : 64-bit
OsLanguage : en-US
OsProductSuites : {TerminalServices}
OsOtherTypeDescription :
OsPAEEnabled :
OsPortableOperatingSystem : False
OsPrimary : True
OsProductType : Server
OsRegisteredUser : My Company
OsSerialNumber : 00492-90000-00001-AA131
OsServicePackMajorVersion : 0
OsServicePackMinorVersion : 0
OsStatus : OK
OsSuites : {TerminalServices}
OsServerLevel : FullServer
KeyboardLayout : sv-SE
TimeZone : (UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna
LogonServer : \\V-DCHLM2
PowerPlatformRole : Desktop
HyperVisorPresent : True
HyperVRequirementDataExecutionPreventionAvailable :
HyperVRequirementSecondLevelAddressTranslation :
HyperVRequirementVirtualizationFirmwareEnabled :
HyperVRequirementVMMonitorModeExtensions :
DeviceGuardSmartStatus : Off
DeviceGuardRequiredSecurityProperties : {0}
DeviceGuardAvailableSecurityProperties : {BaseVirtualizationSupport, SecureBoot, DMAProtection, Secure
MemoryOverwrite...}
DeviceGuardSecurityServicesConfigured : {HypervisorEnforcedCodeIntegrity}
DeviceGuardSecurityServicesRunning : {CredentialGuard, HypervisorEnforcedCodeIntegrity}
DeviceGuardCodeIntegrityPolicyEnforcementStatus : EnforcementMode
DeviceGuardUserModeCodeIntegrityPolicyEnforcementStatus : Off
~~~
~~~
$PSVersionTable
Name Value
---- -----
PSVersion 5.1.26100.32995
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.26100.32995
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
~~~
~~~
Get-Module -Name 'Sampler' -ListAvailable | ft Name,Version,Path
Name Version Path
---- ------- ----
Sampler 0.120.0 C:\Users\admindls\localrepos\UTFwBOM8\output\RequiredModules\Sampler\0.120.0\Sampler.psd1
Sampler 0.120.0 C:\Program Files\WindowsPowerShell\Modules\Sampler\0.120.0\Sampler.psd1
Sampler 0.119.1 C:\Program Files\WindowsPowerShell\Modules\Sampler\0.119.1\Sampler.psd1
~~~
```
Contributor guide
Research direction
Start with build.ps1 and trace how the source Get-Something.ps1 and source .psm1 are combined into the generated .psm1 in output. Reproduce the issue with a UTF-8-with-BOM source file containing the Swedish character, then run .\build.ps1. Done means the generated .psm1 preserves the BOM and the resulting module imports successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100