From 20c6a4313120d6f963479610056d8a64e32e5e18 Mon Sep 17 00:00:00 2001 From: "philip.chinery" Date: Tue, 22 Dec 2015 12:14:08 +0100 Subject: [PATCH] Fix encoding of AssemblyInfo as written by ReplaceAssemblyInfoVersions The function ReplaceAssemblyInfoVersions was reading files with the encoding set by build param or defaulting to the system default. The AssemblyInfo files are always encoded in UTF-8. Therefore, the file encoding that is actually used should not depend on a build param. --- src/app/FakeLib/AssemblyInfoHelper.fs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/FakeLib/AssemblyInfoHelper.fs b/src/app/FakeLib/AssemblyInfoHelper.fs index b63a1484d4b..13f396591f7 100644 --- a/src/app/FakeLib/AssemblyInfoHelper.fs +++ b/src/app/FakeLib/AssemblyInfoHelper.fs @@ -254,10 +254,16 @@ let ReplaceAssemblyInfoVersions param = |> replaceAttribute "AssemblyCopyright" parameters.AssemblyCopyright |> replaceMetadataAttributes parameters.AssemblyMetadata - ReadFile parameters.OutputFileName + let encoding = Text.Encoding.GetEncoding "UTF-8" + + let fileContent = File.ReadAllLines(parameters.OutputFileName, encoding) + + use writer = new StreamWriter(parameters.OutputFileName, false, encoding) + + fileContent |> Seq.map replaceLine |> Seq.toList // break laziness - |> WriteFile parameters.OutputFileName + |> Seq.iter writer.WriteLine /// Update all AssemblyInfo.[fs|cs|vb] files in the specified directory and its subdirectories /// ## Parameters