diff --git a/src/System.Management.Automation/engine/Modules/NewModuleManifestCommand.cs b/src/System.Management.Automation/engine/Modules/NewModuleManifestCommand.cs index 30520c0c5bf..981c9b19af4 100644 --- a/src/System.Management.Automation/engine/Modules/NewModuleManifestCommand.cs +++ b/src/System.Management.Automation/engine/Modules/NewModuleManifestCommand.cs @@ -939,21 +939,17 @@ protected override void EndProcessing() // Now open the output file... PathUtils.MasterStreamOpen( - this, - filePath, -#if UNIX - new UTF8Encoding(false), // UTF-8, no BOM -#else - EncodingConversion.Unicode, // UTF-16 with BOM -#endif - /* defaultEncoding */ false, - /* Append */ false, - /* Force */ false, - /* NoClobber */ false, - out fileStream, - out streamWriter, - out readOnlyFileInfo, - false + cmdlet : this, + filePath : filePath, + resolvedEncoding : new UTF8Encoding(encoderShouldEmitUTF8Identifier : false), + defaultEncoding : false, + Append : false, + Force : false, + NoClobber : false, + fileStream : out fileStream, + streamWriter : out streamWriter, + readOnlyFileInfo : out readOnlyFileInfo, + isLiteralPath : false ); try diff --git a/test/powershell/engine/Module/NewModuleManifest.Tests.ps1 b/test/powershell/engine/Module/NewModuleManifest.Tests.ps1 index 8508db33c1d..ce69ee44ed0 100644 --- a/test/powershell/engine/Module/NewModuleManifest.Tests.ps1 +++ b/test/powershell/engine/Module/NewModuleManifest.Tests.ps1 @@ -1,6 +1,6 @@ Describe "New-ModuleManifest tests" -tags "CI" { BeforeEach { - New-Item -ItemType Directory -Path testdrive:/module + $null = New-Item -ItemType Directory -Path testdrive:/module $testModulePath = "testdrive:/module/test.psd1" } @@ -9,13 +9,10 @@ Describe "New-ModuleManifest tests" -tags "CI" { } BeforeAll { - if ($IsWindows) - { - $ExpectedManifestBytes = @(255,254,35,0,13,0,10,0) - } - else - { - $ExpectedManifestBytes = @(35,10) + if ($IsWindows) { + $ExpectedManifestBytes = @(35,13) # CR + } else { + $ExpectedManifestBytes = @(35,10) # LF } } @@ -38,10 +35,9 @@ Describe "New-ModuleManifest tests" -tags "CI" { } It "Verify module manifest encoding" { - + # verify first line of the manifest: - # on Windows platforms - 3 characters - '#' '\r' '\n' - in UTF-16 with BOM - this should be @(255,254,35,0,13,0,10,0) - # on non-Windows platforms - 2 characters - '#' '\n' - in UTF-8 no BOM - this should be @(35,10) + # 2 characters - '#' '\n' - in UTF-8 no BOM - this should be @(35,10) TestNewModuleManifestEncoding -expected $ExpectedManifestBytes }